[Mesa-dev] [PATCH 6/9] intel/fs: Use the new nir_src_is_const and friends

Jason Ekstrand jason at jlekstrand.net
Wed Nov 7 21:45:59 UTC 2018


On Wed, Nov 7, 2018 at 12:20 PM Kenneth Graunke <kenneth at whitecape.org>
wrote:

> On Saturday, October 20, 2018 10:55:44 AM PST Jason Ekstrand wrote:
> > @@ -553,14 +552,18 @@
> fs_visitor::optimize_frontfacing_ternary(nir_alu_instr *instr,
> >     if (src0->intrinsic != nir_intrinsic_load_front_face)
> >        return false;
> >
> > -   nir_const_value *value1 = nir_src_as_const_value(instr->src[1].src);
> > -   if (!value1 || fabsf(value1->f32[0]) != 1.0f)
> > +   if (!nir_src_is_const(instr->src[1].src) ||
> > +       !nir_src_is_const(instr->src[2].src))
> >        return false;
> >
> > -   nir_const_value *value2 = nir_src_as_const_value(instr->src[2].src);
> > -   if (!value2 || fabsf(value2->f32[0]) != 1.0f)
> > +   const float value1 = nir_src_as_float(instr->src[1].src);
> > +   const float value2 = nir_src_as_float(instr->src[2].src);
> > +   if (fabsf(value1) != 1.0f || fabsf(value2) != 1.0f)
> >        return false;
> >
> > +   /* nir_opt_algebraic should have gotten rid of bcsel(b, a, a) */
> > +   assert(value1 == -value2);
> > +
>
> This is likely true, but it doesn't seem like this belongs in this
> refactoring patch - we weren't doing it before, and no new code appears
> to depend on the condition.


Right.  No *new* code does; but old code definitely does.  Mind if I just
make it a separate commit?


>   Normally I wouldn't mind, but I'm a bit
> paranoid about float equality in assertions.  It's probably fine,
> though, since we ensured fabsf is 1.0f earlier...
> Patches 5-9 are:
> Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20181107/572caaed/attachment-0001.html>


More information about the mesa-dev mailing list