On Thu, Mar 16, 2017 at 2:18 PM, Matt Turner <matts...@gmail.com> wrote:
> --- > src/compiler/nir/nir.h | 2 +- > src/compiler/nir/nir_from_ssa.c | 21 +++++++++++++++------ > 2 files changed, 16 insertions(+), 7 deletions(-) > > diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h > index db47699..0a127cd 100644 > --- a/src/compiler/nir/nir.h > +++ b/src/compiler/nir/nir.h > @@ -2587,7 +2587,7 @@ void nir_convert_loop_to_lcssa(nir_loop *loop); > * registers. If false, convert all values (even those not involved in a > phi > * node) to registers. > */ > -void nir_convert_from_ssa(nir_shader *shader, bool phi_webs_only); > +bool nir_convert_from_ssa(nir_shader *shader, bool phi_webs_only); > > bool nir_lower_phis_to_regs_block(nir_block *block); > bool nir_lower_ssa_defs_to_regs_block(nir_block *block); > diff --git a/src/compiler/nir/nir_from_ssa.c b/src/compiler/nir/nir_from_ > ssa.c > index d2646c6..07fcceb 100644 > --- a/src/compiler/nir/nir_from_ssa.c > +++ b/src/compiler/nir/nir_from_ssa.c > @@ -524,18 +524,21 @@ rewrite_ssa_def(nir_ssa_def *def, void *void_state) > static bool > resolve_registers_block(nir_block *block, struct from_ssa_state *state) > { > + bool progress = false; > + > nir_foreach_instr_safe(instr, block) { > state->instr = instr; > - nir_foreach_ssa_def(instr, rewrite_ssa_def, state); > + progress |= nir_foreach_ssa_def(instr, rewrite_ssa_def, state); > We can't trust the return value here. rewrite_ssa_def *always* returns true regardless of whether or not it works. (It kind-of has to thanks to the way NIR's function pointer based iteration functions work.) I think we need to have a progress boolean in the state structure for this pass. > > if (instr->type == nir_instr_type_phi) { > nir_instr_remove(instr); > ralloc_steal(state->dead_ctx, instr); > + progress = true; > } > } > state->instr = NULL; > > - return true; > + return progress; > } > > static void > @@ -756,10 +759,11 @@ resolve_parallel_copies_block(nir_block *block, > struct from_ssa_state *state) > return true; > } > > -static void > +static bool > nir_convert_from_ssa_impl(nir_function_impl *impl, bool phi_webs_only) > { > struct from_ssa_state state; > + bool progress = false; > > nir_builder_init(&state.builder, impl); > state.dead_ctx = ralloc_context(NULL); > @@ -791,7 +795,7 @@ nir_convert_from_ssa_impl(nir_function_impl *impl, > bool phi_webs_only) > } > > nir_foreach_block(block, impl) { > - resolve_registers_block(block, &state); > + progress |= resolve_registers_block(block, &state); > } > > nir_foreach_block(block, impl) { > @@ -804,15 +808,20 @@ nir_convert_from_ssa_impl(nir_function_impl *impl, > bool phi_webs_only) > /* Clean up dead instructions and the hash tables */ > _mesa_hash_table_destroy(state.merge_node_table, NULL); > ralloc_free(state.dead_ctx); > + return progress; > } > > -void > +bool > nir_convert_from_ssa(nir_shader *shader, bool phi_webs_only) > { > + bool progress = false; > + > nir_foreach_function(function, shader) { > if (function->impl) > - nir_convert_from_ssa_impl(function->impl, phi_webs_only); > + progress |= nir_convert_from_ssa_impl(function->impl, > phi_webs_only); > } > + > + return progress; > } > > > -- > 2.10.2 > > _______________________________________________ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/mesa-dev >
_______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev