From 3df3c38a65c0b362e824c8bd758b431e5f9f197c Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Tue, 21 Feb 2023 08:50:35 +0200 Subject: [PATCH] nir/opt_gcm: allow resource_intel to be moved anywhere 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 Reviewed-by: Kenneth Graunke Part-of: --- src/compiler/nir/nir_opt_gcm.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/compiler/nir/nir_opt_gcm.c b/src/compiler/nir/nir_opt_gcm.c index 8debbe4afa0..b241103aa84 100644 --- a/src/compiler/nir/nir_opt_gcm.c +++ b/src/compiler/nir/nir_opt_gcm.c @@ -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. */