nir/opt_gcm: allow resource_intel to be moved anywhere
authorLionel Landwerlin <lionel.g.landwerlin@intel.com>
Tue, 21 Feb 2023 06:50:35 +0000 (08:50 +0200)
committerMarge Bot <emma+marge@anholt.net>
Tue, 30 May 2023 06:36:37 +0000 (06:36 +0000)
The resouce_intel intrinsic doesn't not result in an actual
instruction, it's just a wrapper around another value, usually a
load_const.

Allowing this intrinsic to be moved anywhere means it's going to be
closer to the value it wraps, enabling opt_gcm to move a load_ubo
using this resource_intel.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21645>

src/compiler/nir/nir_opt_gcm.c

index 8debbe4..b241103 100644 (file)
@@ -531,7 +531,9 @@ set_block_for_loop_instr(struct gcm_state *state, nir_instr *instr,
       return true;
 
    if (instr->type == nir_instr_type_load_const ||
-       instr->type == nir_instr_type_tex)
+       instr->type == nir_instr_type_tex ||
+       (instr->type == nir_instr_type_intrinsic &&
+        nir_instr_as_intrinsic(instr)->intrinsic == nir_intrinsic_resource_intel))
       return true;
 
    return false;
@@ -544,6 +546,10 @@ set_block_to_if_block(struct gcm_state *state,  nir_instr *instr,
    if (instr->type == nir_instr_type_load_const)
       return true;
 
+   if (instr->type == nir_instr_type_intrinsic &&
+       nir_instr_as_intrinsic(instr)->intrinsic == nir_intrinsic_resource_intel)
+      return true;
+
    /* TODO: Figure out some more heuristics to allow more to be moved into
     * if-statements.
     */