[libc] [llvm] [APFloat] Add exp function for APFloat::IEEESsingle using expf implementation from LLVM libc. (PR #143959)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 30 08:41:20 PDT 2025
================
@@ -109,6 +109,18 @@ static constexpr float expf(float x) {
return static_cast<float>(exp_hi * exp_mid * exp_lo);
}
+// Directional rounding version of expf.
+LIBC_INLINE static float expf(float x, int rounding_mode) {
+ int current_rounding_mode = fputil::get_round();
----------------
lntue wrote:
@nikic: Yes, at the moment, all LLVM libc transcendental math functions are rounded toward the current (dynamic) floating point environment rounding mode (https://libc.llvm.org/headers/math/index.html#implementation-requirements-goals), and we test them for all 4 rounding modes (FE_NEAREST, FE_UPWARD, FE_DOWNWARD, and FE_TOWARDZERO) against MPFR outputs.
Some examples in our test suites:
- double precision exp: https://github.com/llvm/llvm-project/blob/main/libc/test/src/math/exp_test.cpp
- assertion macros comparing against MPFR for all rounding modes: https://github.com/llvm/llvm-project/blob/main/libc/utils/MPFRWrapper/MPFRUtils.h#L414
- exhaustive test for single precision expf: https://github.com/llvm/llvm-project/blob/main/libc/test/src/math/exhaustive/expf_test.cpp
using the test template: https://github.com/llvm/llvm-project/blob/main/libc/test/src/math/exhaustive/exhaustive_test.h#L213
https://github.com/llvm/llvm-project/pull/143959
More information about the llvm-commits
mailing list