[libc] Add implementation of expm1f.
authorTue Ly <lntue@google.com>
Fri, 23 Apr 2021 04:38:59 +0000 (00:38 -0400)
committerTue Ly <lntue@google.com>
Thu, 10 Jun 2021 18:58:34 +0000 (14:58 -0400)
commit4e5f8b4d8d9d7a6039e10b9507dac896eed92040
tree1dea35be0314a8430b957aff9a48fc5395fb5b25
parentc0e6f2f43a4cf894173b78cc95b6c29c9fe1ab94
[libc] Add implementation of expm1f.

Use expm1f(x) = exp(x) - 1 for |x| > ln(2).
For |x| <= ln(2), divide it into 3 subintervals: [-ln2, -1/8], [-1/8, 1/8], [1/8, ln2]
and use a degree-6 polynomial approximation generated by Sollya's fpminmax for each interval.
Errors < 1.5 ULPs when we use fma to evaluate the polynomials.

Differential Revision: https://reviews.llvm.org/D101134
21 files changed:
libc/config/linux/aarch64/entrypoints.txt
libc/config/linux/x86_64/entrypoints.txt
libc/spec/stdc.td
libc/src/math/CMakeLists.txt
libc/src/math/expm1f.h [new file with mode: 0644]
libc/src/math/generic/CMakeLists.txt
libc/src/math/generic/expm1f.cpp [new file with mode: 0644]
libc/test/src/math/CMakeLists.txt
libc/test/src/math/differential_testing/CMakeLists.txt
libc/test/src/math/differential_testing/expm1f_diff.cpp [new file with mode: 0644]
libc/test/src/math/differential_testing/expm1f_perf.cpp [new file with mode: 0644]
libc/test/src/math/exhaustive/CMakeLists.txt
libc/test/src/math/exhaustive/expm1f_test.cpp [new file with mode: 0644]
libc/test/src/math/expm1f_test.cpp [new file with mode: 0644]
libc/utils/FPUtil/BitPatterns.h
libc/utils/FPUtil/CMakeLists.txt
libc/utils/FPUtil/PolyEval.h [new file with mode: 0644]
libc/utils/FPUtil/generic/FMA.h
libc/utils/MPFRWrapper/MPFRUtils.cpp
libc/utils/MPFRWrapper/MPFRUtils.h
libc/utils/mathtools/expm1f.sollya [new file with mode: 0644]