[Mesa-dev] [PATCH] nir: Optimize double-precision lower_round_even()

Philipp Zabel p.zabel at pengutronix.de
Tue Jan 29 09:55:10 UTC 2019


On Tue, 2019-01-29 at 10:10 +0100, Erik Faye-Lund wrote:
> On Mon, 2019-01-28 at 09:31 -0800, Matt Turner wrote:
> > Use the trick of adding and then subtracting 2**52 (52 is the number
> > of
> > explicit mantissa bits a double-precision floating-point value has)
> > to
> > implement round-to-even.
> > 
> > Cuts the number of instructions on SKL of the piglit test
> > fs-roundEven-double.shader_test from 109 to 21.
> 
> Won't this approach only work for "small" values, that is values equal
> to or smaller than DBL_MAX - 2**52? Once you add 2**52, you'll get
> infinity, and you can't subtract 2**52 away again without being stuck
> with infinity, no...

2**52 is such a small value compared to anything close to DBL_MAX, it
will just be absorbed.

regards
Philipp


More information about the mesa-dev mailing list