From bf7ee3de20f43afd353d4f8dc97eb6192b124c91 Mon Sep 17 00:00:00 2001 From: Georg Lehmann Date: Fri, 4 Jul 2025 11:48:07 +0200 Subject: [PATCH] nir/opt_remove_phis: skip unreachable phis MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit block->imm_dom is NULL for unreachable phis, so the dominance checks would crash. These blocks should be removed by nir_opt_dead_cf, so don't bother optimizing them here. Fixes: 60776f87c38 ("nir/opt_remove_phis: rematerialize constants") Reviewed-by: Daniel Schürmann Reviewed-by: Ian Romanick Part-of: (cherry picked from commit fcc9203550ec9e964feca8f301d59c2b1202d517) --- .pick_status.json | 2 +- src/compiler/nir/nir_opt_remove_phis.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.pick_status.json b/.pick_status.json index 0ff5d9e6e08..464eb779160 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -3144,7 +3144,7 @@ "description": "nir/opt_remove_phis: skip unreachable phis", "nominated": true, "nomination_type": 2, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "60776f87c38f69507d60591b46b3ea2efba8e188", "notes": null diff --git a/src/compiler/nir/nir_opt_remove_phis.c b/src/compiler/nir/nir_opt_remove_phis.c index 283acd59ff1..7f126a79834 100644 --- a/src/compiler/nir/nir_opt_remove_phis.c +++ b/src/compiler/nir/nir_opt_remove_phis.c @@ -95,6 +95,10 @@ remove_phis_instr(nir_builder *b, nir_phi_instr *phi, void *unused) nir_def *def = NULL; bool needs_remat = false; + /* Skip unreachable phis, they should be removed by nir_opt_dead_cf. */ + if (nir_block_is_unreachable(block)) + return false; + nir_foreach_phi_src(src, phi) { /* For phi nodes at the beginning of loops, we may encounter some * sources from backedges that point back to the destination of the