[libc][math] Update range reduction step for log2f and improve its performance.
authorTue Ly <lntue@google.com>
Fri, 7 Apr 2023 02:38:04 +0000 (22:38 -0400)
committerTue Ly <lntue@google.com>
Tue, 11 Apr 2023 13:43:23 +0000 (09:43 -0400)
commit92bc7f5428168535cb1ee6c92f739f0b7f72aa5d
tree9f24f0c806ef09b377bfa3a666e6c905f91060ce
parentd8a0dc425cbf2fdf8415976560b4379bbb976c83
[libc][math] Update range reduction step for log2f and improve its performance.

Simplify the range reduction steps by choosing the reduction constants
carefully so that the reduced arguments v = r*m_x - 1 and v^2 are exact in double
precision, even without FMA instructions, and -2^-8 <= v < 2^-7.

Reviewed By: zimmermann6

Differential Revision: https://reviews.llvm.org/D147759
libc/src/math/generic/log2f.cpp
libc/test/src/math/log2f_test.cpp