diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 1c3292268df..e732efaaa7a 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -2615,6 +2615,18 @@ typedef struct { nir_dest dest; } nir_phi_instr; +static inline nir_phi_src * +nir_phi_get_src_from_block(nir_phi_instr *phi, struct nir_block *block) +{ + nir_foreach_phi_src(src, phi) { + if (src->pred == block) + return src; + } + + assert(!"Block is not a predecessor of phi."); + return NULL; +} + typedef struct { struct exec_node node; nir_src src; diff --git a/src/compiler/nir/nir_opt_if.c b/src/compiler/nir/nir_opt_if.c index 31195b12bb7..7b0a91e47d2 100644 --- a/src/compiler/nir/nir_opt_if.c +++ b/src/compiler/nir/nir_opt_if.c @@ -509,21 +509,6 @@ opt_split_alu_of_phi(nir_builder *b, nir_loop *loop) return progress; } -/** - * Get the SSA value from a phi node that corresponds to a specific block - */ -static nir_ssa_def * -ssa_for_phi_from_block(nir_phi_instr *phi, nir_block *block) -{ - nir_foreach_phi_src(src, phi) { - if (src->pred == block) - return src->src.ssa; - } - - assert(!"Block is not a predecessor of phi."); - return NULL; -} - /** * Simplify a bcsel whose sources are all phi nodes from the loop header block * @@ -681,15 +666,15 @@ opt_simplify_bcsel_of_phi(nir_builder *b, nir_loop *loop) phi_src = ralloc(phi, nir_phi_src); phi_src->pred = prev_block; phi_src->src = - nir_src_for_ssa(ssa_for_phi_from_block(nir_instr_as_phi(bcsel->src[entry_src].src.ssa->parent_instr), - prev_block)); + nir_phi_get_src_from_block(nir_instr_as_phi(bcsel->src[entry_src].src.ssa->parent_instr), + prev_block)->src; exec_list_push_tail(&phi->srcs, &phi_src->node); phi_src = ralloc(phi, nir_phi_src); phi_src->pred = continue_block; phi_src->src = - nir_src_for_ssa(ssa_for_phi_from_block(nir_instr_as_phi(bcsel->src[continue_src].src.ssa->parent_instr), - continue_block)); + nir_phi_get_src_from_block(nir_instr_as_phi(bcsel->src[continue_src].src.ssa->parent_instr), + continue_block)->src; exec_list_push_tail(&phi->srcs, &phi_src->node); nir_ssa_dest_init(&phi->instr,