[Mesa-dev] [PATCH v2] nir/algebraic: Add optimizations for "a == a && a CMP b"

Jason Ekstrand jason at jlekstrand.net
Thu Dec 22 22:27:20 UTC 2016


On Thu, Dec 22, 2016 at 2:21 PM, Ian Romanick <idr at freedesktop.org> wrote:

> Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
>

Thanks!


> On 12/22/2016 01:54 PM, Jason Ekstrand wrote:
> > This sequence shows up The Talos Principal, at least under Vulkan,
> > and prevents loop analysis from properly computing trip counts in a
> > few loops.
> > ---
> >  src/compiler/nir/nir_opt_algebraic.py | 8 ++++++++
> >  1 file changed, 8 insertions(+)
> >
> > diff --git a/src/compiler/nir/nir_opt_algebraic.py
> b/src/compiler/nir/nir_opt_algebraic.py
> > index 698ac67..ff10d70 100644
> > --- a/src/compiler/nir/nir_opt_algebraic.py
> > +++ b/src/compiler/nir/nir_opt_algebraic.py
> > @@ -464,6 +464,14 @@ def bitfield_reverse(u):
> >
> >  optimizations += [(bitfield_reverse('x at 32'), ('bitfield_reverse',
> 'x'))]
> >
> > +# For any float comparison operation, "cmp", if you have "a == a && a
> cmp b"
> > +# then the "a == a" is redundant because it's equivalent to "a is not
> NaN"
> > +# and, if a is a NaN then the second comparison will fail anyway.
> > +for op in ['flt', 'fge', 'feq']:
> > +   optimizations += [
> > +      (('iand', ('feq', a, a), (op, a, b)), (op, a, b)),
> > +      (('iand', ('feq', a, a), (op, b, a)), (op, b, a)),
> > +   ]
> >
> >  # Add optimizations to handle the case where the result of a ternary is
> >  # compared to a constant.  This way we can take things like
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20161222/994527be/attachment-0001.html>


More information about the mesa-dev mailing list