[libc-commits] [libc] cbfac21 - [libc][mathvec] Cover the non-FMA expf rounding correction (#241112)

via libc-commits libc-commits at lists.llvm.org
Sat Nov 14 20:08:14 PST 2026


Author: sriramshastry
Date: 2026-11-15T09:38:09+05:30
New Revision: cbfac21cd384f6c7c480c2d0026ecedfe2d619e7

URL: https://github.com/llvm/llvm-project/commit/cbfac21cd384f6c7c480c2d0026ecedfe2d619e7
DIFF: https://github.com/llvm/llvm-project/commit/cbfac21cd384f6c7c480c2d0026ecedfe2d619e7.diff

LOG: [libc][mathvec] Cover the non-FMA expf rounding correction (#241112)

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

Signed-off-by: sriramshastry <sriramshastry at gmail.com>

Added: 
    

Modified: 
    libc/test/src/mathvec/expf_test.cpp

Removed: 
    


################################################################################
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); }


        


More information about the libc-commits mailing list