[Mesa-dev] [PATCH 4/4] nir: Add some asserts that we don't put derefs in phis

Jason Ekstrand jason at jlekstrand.net
Tue Sep 18 10:08:44 UTC 2018


Yeah, that's a good idea. I'll do that.

On Tue, Sep 18, 2018 at 4:03 AM Iago Toral <itoral at igalia.com> wrote:

> Should we add a similar check to validate_phi_src in nir_validate.c?
>
> On Mon, 2018-09-17 at 09:43 -0500, Jason Ekstrand wrote:
> > The lcssa and phis_to_regs passes are used by various NIR
> > optimizations
> > that modify the CFG.  Putting a couple of asserts will help ensure
> > that
> > we don't accidentally put derefs in phis as part of an optimization
> > pass.
> > ---
> >  src/compiler/nir/nir_from_ssa.c | 2 ++
> >  src/compiler/nir/nir_to_lcssa.c | 3 +++
> >  2 files changed, 5 insertions(+)
> >
> > diff --git a/src/compiler/nir/nir_from_ssa.c
> > b/src/compiler/nir/nir_from_ssa.c
> > index 1aa35509b11..19d4bc33820 100644
> > --- a/src/compiler/nir/nir_from_ssa.c
> > +++ b/src/compiler/nir/nir_from_ssa.c
> > @@ -901,6 +901,8 @@ nir_lower_phis_to_regs_block(nir_block *block)
> >
> >        nir_foreach_phi_src(src, phi) {
> >           assert(src->src.is_ssa);
> > +         /* We don't want derefs ending up in phi sources */
> > +         assert(!nir_src_as_deref(src->src));
> >           place_phi_read(shader, reg, src->src.ssa, src->pred);
> >        }
> >
> > diff --git a/src/compiler/nir/nir_to_lcssa.c
> > b/src/compiler/nir/nir_to_lcssa.c
> > index 9b3539193ea..0f62fc39400 100644
> > --- a/src/compiler/nir/nir_to_lcssa.c
> > +++ b/src/compiler/nir/nir_to_lcssa.c
> > @@ -111,6 +111,9 @@ convert_loop_exit_for_ssa(nir_ssa_def *def, void
> > *void_state)
> >     if (all_uses_inside_loop)
> >        return true;
> >
> > +   /* We don't want derefs ending up in phi sources */
> > +   assert(def->parent_instr->type != nir_instr_type_deref);
> > +
> >     /* Initialize a phi-instruction */
> >     nir_phi_instr *phi = nir_phi_instr_create(state->shader);
> >     nir_ssa_dest_init(&phi->instr, &phi->dest,
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20180918/a5c5ead1/attachment-0001.html>


More information about the mesa-dev mailing list