nir/opt_remove_phis: skip unreachable phis

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: 60776f87c3 ("nir/opt_remove_phis: rematerialize constants")
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35935>
This commit is contained in:
Georg Lehmann 2025-07-04 11:48:07 +02:00 committed by Marge Bot
parent f4166ab1e1
commit fcc9203550

View file

@ -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