diff options
author | Connor Abbott <[email protected]> | 2019-06-04 13:02:31 +0200 |
---|---|---|
committer | Juan A. Suarez Romero <[email protected]> | 2019-07-15 09:34:37 +0000 |
commit | 8bc7397e02d26b6413ee2dd3763069f0af8281bd (patch) | |
tree | 6b9a88cd2341d4c58ca15c1f1d0acd9a4f4c1fda | |
parent | 83c4597f19e7e1d200e44c8d6ea2fe0a55ddb09d (diff) |
nir: Add a helper to determine if an intrinsic can be reordered
This is simple now, but we're going to be adding a few more conditions
to this later.
Reviewed-by: Timothy Arceri <[email protected]>
(cherry picked from commit a1c737927c0d96f26ce487930aa9a2ed323814c9)
-rw-r--r-- | src/compiler/nir/nir.h | 10 | ||||
-rw-r--r-- | src/compiler/nir/nir_instr_set.c | 8 | ||||
-rw-r--r-- | src/compiler/nir/nir_opt_gcm.c | 6 |
3 files changed, 13 insertions, 11 deletions
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 98940b5fb19..88e2f95c8fb 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -1416,6 +1416,16 @@ nir_intrinsic_align(const nir_intrinsic_instr *intrin) void nir_rewrite_image_intrinsic(nir_intrinsic_instr *instr, nir_ssa_def *handle, bool bindless); +/* Determine if an intrinsic can be arbitrarily reordered and eliminated. */ +static inline bool +nir_intrinsic_can_reorder(nir_intrinsic_instr *instr) +{ + const nir_intrinsic_info *info = + &nir_intrinsic_infos[instr->intrinsic]; + return (info->flags & NIR_INTRINSIC_CAN_ELIMINATE) && + (info->flags & NIR_INTRINSIC_CAN_REORDER); +} + /** * \group texture information * diff --git a/src/compiler/nir/nir_instr_set.c b/src/compiler/nir/nir_instr_set.c index 2dc0ef6fec9..2e5e47f5eef 100644 --- a/src/compiler/nir/nir_instr_set.c +++ b/src/compiler/nir/nir_instr_set.c @@ -749,12 +749,8 @@ instr_can_rewrite(nir_instr *instr) case nir_instr_type_load_const: case nir_instr_type_phi: return true; - case nir_instr_type_intrinsic: { - const nir_intrinsic_info *info = - &nir_intrinsic_infos[nir_instr_as_intrinsic(instr)->intrinsic]; - return (info->flags & NIR_INTRINSIC_CAN_ELIMINATE) && - (info->flags & NIR_INTRINSIC_CAN_REORDER); - } + case nir_instr_type_intrinsic: + return nir_intrinsic_can_reorder(nir_instr_as_intrinsic(instr)); case nir_instr_type_call: case nir_instr_type_jump: case nir_instr_type_ssa_undef: diff --git a/src/compiler/nir/nir_opt_gcm.c b/src/compiler/nir/nir_opt_gcm.c index e7d3f8ec424..aeae2ad6401 100644 --- a/src/compiler/nir/nir_opt_gcm.c +++ b/src/compiler/nir/nir_opt_gcm.c @@ -152,11 +152,7 @@ gcm_pin_instructions_block(nir_block *block, struct gcm_state *state) break; case nir_instr_type_intrinsic: { - const nir_intrinsic_info *info = - &nir_intrinsic_infos[nir_instr_as_intrinsic(instr)->intrinsic]; - - if ((info->flags & NIR_INTRINSIC_CAN_ELIMINATE) && - (info->flags & NIR_INTRINSIC_CAN_REORDER)) { + if (nir_intrinsic_can_reorder(nir_instr_as_intrinsic(instr))) { instr->pass_flags = 0; } else { instr->pass_flags = GCM_INSTR_PINNED; |