nir: Use nir_foreach_phi(_safe)

The pattern shows up all the time open-coded. Use the macro instead.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Konstantin Seurer <konstantin.seurer@gmail.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22967>
This commit is contained in:
Alyssa Rosenzweig
2023-05-11 13:20:43 -04:00
committed by Marge Bot
parent 7dc297cc14
commit aa6bdbd54a
15 changed files with 48 additions and 163 deletions
+2 -7
View File
@@ -68,12 +68,7 @@ remove_phis_block(nir_block *block, nir_builder *b)
{
bool progress = false;
nir_foreach_instr_safe(instr, block) {
if (instr->type != nir_instr_type_phi)
break;
nir_phi_instr *phi = nir_instr_as_phi(instr);
nir_foreach_phi_safe(phi, block) {
nir_ssa_def *def = NULL;
nir_alu_instr *mov = NULL;
bool srcs_same = true;
@@ -133,7 +128,7 @@ remove_phis_block(nir_block *block, nir_builder *b)
assert(phi->dest.is_ssa);
nir_ssa_def_rewrite_uses(&phi->dest.ssa, def);
nir_instr_remove(instr);
nir_instr_remove(&phi->instr);
progress = true;
}