diff --git a/src/compiler/nir/nir_from_ssa.c b/src/compiler/nir/nir_from_ssa.c index a7cfc4ed13b..a903073d829 100644 --- a/src/compiler/nir/nir_from_ssa.c +++ b/src/compiler/nir/nir_from_ssa.c @@ -376,13 +376,9 @@ get_parallel_copy_at_end_of_block(nir_block *block) static bool isolate_phi_nodes_block(nir_shader *shader, nir_block *block, void *dead_ctx) { - nir_instr *last_phi_instr = NULL; - nir_foreach_phi(phi, block) { - last_phi_instr = &phi->instr; - } - /* If we don't have any phis, then there's nothing for us to do. */ - if (last_phi_instr == NULL) + nir_phi_instr *last_phi = nir_block_last_phi_instr(block); + if (last_phi == NULL) return true; /* If we have phi nodes, we need to create a parallel copy at the @@ -390,7 +386,7 @@ isolate_phi_nodes_block(nir_shader *shader, nir_block *block, void *dead_ctx) */ nir_parallel_copy_instr *block_pcopy = nir_parallel_copy_instr_create(shader); - nir_instr_insert_after(last_phi_instr, &block_pcopy->instr); + nir_instr_insert_after(&last_phi->instr, &block_pcopy->instr); nir_foreach_phi(phi, block) { assert(phi->dest.is_ssa); diff --git a/src/compiler/nir/nir_lower_phis_to_scalar.c b/src/compiler/nir/nir_lower_phis_to_scalar.c index 2fc86bb609f..7d86256f21a 100644 --- a/src/compiler/nir/nir_lower_phis_to_scalar.c +++ b/src/compiler/nir/nir_lower_phis_to_scalar.c @@ -186,12 +186,7 @@ lower_phis_to_scalar_block(nir_block *block, struct lower_phis_to_scalar_state *state) { bool progress = false; - - /* Find the last phi node in the block */ - nir_phi_instr *last_phi = NULL; - nir_foreach_phi(phi, block) { - last_phi = phi; - } + nir_phi_instr *last_phi = nir_block_last_phi_instr(block); /* We have to handle the phi nodes in their own pass due to the way * we're modifying the linked list of instructions.