[Mesa-dev] [PATCH 22/59] compiler/nir: add lowering for 16-bit ldexp

Pohjolainen, Topi topi.pohjolainen at gmail.com
Wed Dec 5 11:20:42 UTC 2018


On Wed, Dec 05, 2018 at 11:53:44AM +0100, Iago Toral wrote:
> On Wed, 2018-12-05 at 11:39 +0200, Pohjolainen, Topi wrote:
> > I remember people preferring to order things 16, 32, 64 before.
> > Should
> > we follow that here as well?
> 
> Yes, it makes sense. I'll change that.
> 
> > On Tue, Dec 04, 2018 at 08:16:46AM +0100, Iago Toral Quiroga wrote:
> > > ---
> > >  src/compiler/nir/nir_opt_algebraic.py | 5 +++++
> > >  1 file changed, 5 insertions(+)
> > > 
> > > diff --git a/src/compiler/nir/nir_opt_algebraic.py
> > > b/src/compiler/nir/nir_opt_algebraic.py
> > > index 6c3b77c9b6e..747f1751086 100644
> > > --- a/src/compiler/nir/nir_opt_algebraic.py
> > > +++ b/src/compiler/nir/nir_opt_algebraic.py
> > > @@ -778,6 +778,8 @@ def fexp2i(exp, bits):
> > >        return ('ishl', ('iadd', exp, 127), 23)
> > >     elif bits == 64:
> > >        return ('pack_64_2x32_split', 0, ('ishl', ('iadd', exp,
> > > 1023), 20))
> > > +   elif bits == 16:
> > > +      return ('i2i16', ('ishl', ('iadd', exp, 15), 10))
> > >     else:
> > >        assert False
> > >  
> > > @@ -796,6 +798,8 @@ def ldexp(f, exp, bits):
> > >        exp = ('imin', ('imax', exp, -252), 254)
> > >     elif bits == 64:
> > >        exp = ('imin', ('imax', exp, -2044), 2046)
> > > +   elif bits == 16:
> > > +      exp = ('imin', ('imax', exp, -30), 30)
> > 
> > I expected this to be:
> > 
> >          exp = ('imin', ('imax', exp, -29), 30)
> 
> Actually, I think this should be -28, since the minimum exponent value
> is -14.

I kept wondering about. The offset is 15 and -14 - 15 yields -29. But -28
in turn would be more in line with the 32- and 64-bit cases.

> 
> > >     else:
> > >        assert False
> > >  
> > > @@ -814,6 +818,7 @@ def ldexp(f, exp, bits):
> > >  optimizations += [
> > >     (('ldexp at 32', 'x', 'exp'), ldexp('x', 'exp', 32), 'options-
> > > >lower_ldexp'),
> > >     (('ldexp at 64', 'x', 'exp'), ldexp('x', 'exp', 64), 'options-
> > > >lower_ldexp'),
> > > +   (('ldexp at 16', 'x', 'exp'), ldexp('x', 'exp', 16), 'options-
> > > >lower_ldexp'),
> > >  ]
> > >  
> > >  # Unreal Engine 4 demo applications open-codes bitfieldReverse()
> > > -- 
> > > 2.17.1
> > > 
> > > _______________________________________________
> > > mesa-dev mailing list
> > > mesa-dev at lists.freedesktop.org
> > > https://lists.freedesktop.org/mailman/listinfo/mesa-dev
> > 
> > 
> 


More information about the mesa-dev mailing list