From 4d30564f2b538faaca83a6f28f371da3d2c08dfa 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: (cherry picked from commit 8fd5266b691b796eae1d00322e363fb857e04408) --- .pick_status.json | 2 +- src/compiler/nir/nir_divergence_analysis.c | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index abc2c47a9ed..08d71c9402f 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -1784,7 +1784,7 @@ "description": "nir/divergence: ignore boolean phis for ignore_undef_if_phi_srcs", "nominated": true, "nomination_type": 4, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null, "notes": null diff --git a/src/compiler/nir/nir_divergence_analysis.c b/src/compiler/nir/nir_divergence_analysis.c index f0e2a5742f1..4a8102436f6 100644 --- a/src/compiler/nir/nir_divergence_analysis.c +++ b/src/compiler/nir/nir_divergence_analysis.c @@ -1371,7 +1371,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); }