[libc] Implement expm1f function that is correctly rounded for all rounding modes.
authorTue Ly <lntue@google.com>
Mon, 14 Mar 2022 13:43:33 +0000 (09:43 -0400)
committerTue Ly <lntue@google.com>
Tue, 15 Mar 2022 14:24:56 +0000 (10:24 -0400)
commit64af346b185ab3c3c34e145181717350c304b05a
tree9717fa456ed31059100e5ecaf5135d6421f1884a
parent7e4cf582cffdc287a0d6ee354e90a4fbdc5a696d
[libc] Implement expm1f function that is correctly rounded for all rounding modes.

Implement expm1f function that is correctly rounded for all rounding modes.  This is based on expf implementation.

From exhaustive testings, using expf implementation, and subtract 1.0 before rounding the final result to single precision
gives correctly rounded results for all |x| > 2^-4 with 1 exception.  When |x| < 2^-25, we use x + x^2 (implemented with a
single fma).  And for 2^-25 <= |x| <= 2^-4, we use a single degree-8 minimax polynomial generated by Sollya.

Reviewed By: sivachandra, zimmermann6

Differential Revision: https://reviews.llvm.org/D121574
libc/src/math/generic/CMakeLists.txt
libc/src/math/generic/common_constants.cpp
libc/src/math/generic/common_constants.h
libc/src/math/generic/expf.cpp
libc/src/math/generic/expm1f.cpp
libc/test/src/math/exhaustive/CMakeLists.txt
libc/test/src/math/exhaustive/exhaustive_test.cpp
libc/test/src/math/exhaustive/exhaustive_test.h
libc/test/src/math/exhaustive/expm1f_test.cpp
libc/test/src/math/expm1f_test.cpp