From 0521027182cdae1b6008a23354a722661ef231ff Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 17 Nov 2022 01:59:37 -0800 Subject: [PATCH] nir: Allow more than just ALU instructions in 'weak' GVN This removes the ALU-only restriction on the "weak" GVN introduced by the previous commit. This makes it slightly more aggressive, allowing it to coalesce things like UBO loads (still within sister then/else blocks). This also can have surprisingly large cascading effects. I was concerned that this might increase register pressure, but shader-db and fossil-db show effectively no change in spills/fills, so it seems to be fine. Reviewed-by: Ian Romanick Part-of: --- src/compiler/nir/nir_opt_gcm.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/compiler/nir/nir_opt_gcm.c b/src/compiler/nir/nir_opt_gcm.c index d0cb8f9..2770fdc 100644 --- a/src/compiler/nir/nir_opt_gcm.c +++ b/src/compiler/nir/nir_opt_gcm.c @@ -792,14 +792,11 @@ gcm_place_instr(nir_instr *instr, struct gcm_state *state) } /** - * Are ALU instructions a and b both contained in the same if/else block? + * Are instructions a and b both contained in the same if/else block? */ static bool weak_gvn(const nir_instr *a, const nir_instr *b) { - if (a->type != nir_instr_type_alu) - return false; - const struct nir_cf_node *ap = a->block->cf_node.parent; const struct nir_cf_node *bp = b->block->cf_node.parent; return ap && ap == bp && ap->type == nir_cf_node_if; -- 2.7.4