Replace int2float() with an optimized version.

We use __fls() to find the most significant bit.  Using that, the
loop can be avoided.  A second trick is to use the behaviour of the
rotate instructions to expand the range of the unsigned int to float
conversion to the full 32 bits in a branchless way.

The routine is now exact up to 2^24.  Above that, we truncate which
is equivalent to rounding towards zero.

Signed-off-by: Steven Fuerst <svfuerst@gmail.com>
This commit is contained in:
Steven Fuerst 2012-08-15 15:07:15 -07:00 • committed by Alex Deucher
commit 747f49ba67