[libc-commits] [libc] [libc][math][c23] fixing dfmal for rv32 (PR #101763)

via libc-commits libc-commits at lists.llvm.org
Fri Aug 2 15:23:21 PDT 2024


https://github.com/aaryanshukla created https://github.com/llvm/llvm-project/pull/101763

None

>From a7935b6cf1151fc556679dcaa0405b77151d1511 Mon Sep 17 00:00:00 2001
From: Aaryan Shukla <aaryanshukla at google.com>
Date: Fri, 2 Aug 2024 22:22:34 +0000
Subject: [PATCH] [libc][math][c23] fixing dfmal for rv32

---
 libc/test/src/math/smoke/FmaTest.h | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/libc/test/src/math/smoke/FmaTest.h b/libc/test/src/math/smoke/FmaTest.h
index f942de37654dd..bf6d06d698fde 100644
--- a/libc/test/src/math/smoke/FmaTest.h
+++ b/libc/test/src/math/smoke/FmaTest.h
@@ -67,12 +67,14 @@ class FmaTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
                          out.min_normal));
 
     if constexpr (sizeof(OutType) < sizeof(InType)) {
+      InFPBits tmp = InFPBits::one();
+      tmp.set_biased_exponent(InFPBits::EXP_BIAS - InFPBits::FRACTION_LEN - 1);
+      InType reciprocal_value = tmp.get_val();
+
       InType v = InFPBits(static_cast<InStorageType>(IN_MIN_NORMAL_U +
                                                      InStorageType(1)))
                      .get_val();
-      EXPECT_FP_EQ(
-          out.min_normal,
-          func(InType(1) / InType(IN_MIN_NORMAL_U << 1), v, out.min_normal));
+      EXPECT_FP_EQ(out.min_normal, func(reciprocal_value, v, out.min_normal));
     }
 
     // Test overflow.



More information about the libc-commits mailing list