From 8fd5266b691b796eae1d00322e363fb857e04408 Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Wed, 16 Jul 2025 14:49:32 +0100 Subject: [PATCH] nir/divergence: ignore boolean phis for ignore_undef_if_phi_srcs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The only user of this option (ACO) doesn't support this for boolean phis. fossil-db (navi21): Totals from 1208 (1.51% of 79825) affected shaders: Instrs: 826592 -> 823201 (-0.41%); split: -0.41%, +0.00% CodeSize: 4228296 -> 4224280 (-0.09%); split: -0.11%, +0.01% Latency: 3030803 -> 3028410 (-0.08%); split: -0.08%, +0.01% InvThroughput: 578588 -> 578693 (+0.02%); split: -0.00%, +0.02% VClause: 19500 -> 19494 (-0.03%) Copies: 60914 -> 57589 (-5.46%); split: -5.47%, +0.01% PreVGPRs: 50759 -> 50774 (+0.03%) VALU: 528582 -> 528671 (+0.02%); split: -0.00%, +0.02% SALU: 121134 -> 117646 (-2.88%) Signed-off-by: Rhys Perry Reviewed-by: Georg Lehmann Reviewed-by: Daniel Schürmann Backport-to: 25.1 Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/13455 Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/13509 Part-of: --- src/compiler/nir/nir_divergence_analysis.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/compiler/nir/nir_divergence_analysis.c b/src/compiler/nir/nir_divergence_analysis.c index b31d7098c2d..b00c7c92eb4 100644 --- a/src/compiler/nir/nir_divergence_analysis.c +++ b/src/compiler/nir/nir_divergence_analysis.c @@ -1372,7 +1372,11 @@ visit_if(nir_if *if_stmt, struct divergence_state *state) phi->def.loop_invariant = invariant && nir_foreach_src(&phi->instr, src_invariant, state->loop); } - bool ignore_undef = state->options & nir_divergence_ignore_undef_if_phi_srcs; + + /* The only user of this option (ACO) only supports it for non-boolean phis. */ + bool ignore_undef = + (state->options & nir_divergence_ignore_undef_if_phi_srcs) && phi->def.bit_size != 1; + progress |= visit_if_merge_phi(phi, cond_divergent, ignore_undef); }