[libc-commits] [libc] [libc][mathvec] Cover the non-FMA expf rounding correction (PR #241112)
via libc-commits
libc-commits at lists.llvm.org
Tue Nov 10 20:11:41 PST 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libc
Author: sriramshastry
<details>
<summary>Changes</summary>
Add a targeted regression for 0xc16912cd and adjacent inputs, covering broadcast and every mixed-lane position with the existing scalar reference.
Assisted-by: GitHub Copilot
---
Full diff: https://github.com/llvm/llvm-project/pull/241112.diff
1 Files Affected:
- (modified) libc/test/src/mathvec/expf_test.cpp (+16)
``````````diff
diff --git a/libc/test/src/mathvec/expf_test.cpp b/libc/test/src/mathvec/expf_test.cpp
index 18b6b398b5b6cd..455581bc103990 100644
--- a/libc/test/src/mathvec/expf_test.cpp
+++ b/libc/test/src/mathvec/expf_test.cpp
@@ -82,4 +82,20 @@ TEST_F(LlvmLibcVecExpfTest, Borderline) {
EXPECT_SIMD_EQ(wrap_ref<ExpfOp>(x, 1.0), wrap_vector<ExpfOp>(x, 1.0));
}
+TEST_F(LlvmLibcVecExpfTest, NonFMAHardToRound) {
+ // The middle input needs an explicit correction without double-precision FMA.
+ constexpr uint32_t INPUTS[] = {0xc16912ccU, 0xc16912cdU, 0xc16912ceU};
+ constexpr size_t LANES =
+ LIBC_NAMESPACE::cpp::internal::native_vector_size<float>;
+ for (uint32_t bits : INPUTS) {
+ float x = FPBits(bits).get_val();
+ EXPECT_SIMD_EQ(wrap_ref<ExpfOp>(x), wrap_vector<ExpfOp>(x));
+ for (size_t lane = 0; lane < LANES; ++lane) {
+ LIBC_NAMESPACE::cpp::simd<float> input(1.0f);
+ input[lane] = x;
+ EXPECT_SIMD_EQ(ExpfOp::eval_scalar(input), ExpfOp::eval_vector(input));
+ }
+ }
+}
+
TEST_F(LlvmLibcVecExpfTest, InFloatRange) { TEST_MATHVEC_FLOAT_RANGE(ExpfOp); }
``````````
</details>
https://github.com/llvm/llvm-project/pull/241112
More information about the libc-commits
mailing list