[libc-commits] [libc] [libc][math][c23] Fix setpayloadsig smoke test on RV32 (PR #102538)
Job Henandez Lara via libc-commits
libc-commits at lists.llvm.org
Thu Aug 8 15:06:39 PDT 2024
https://github.com/Jobhdez updated https://github.com/llvm/llvm-project/pull/102538
>From 76d04246ab751b647f7b15b85feec0a3147aa595 Mon Sep 17 00:00:00 2001
From: Job Hernandez <hj93 at protonmail.com>
Date: Thu, 8 Aug 2024 14:03:00 -0700
Subject: [PATCH 1/4] fix bug
---
libc/test/src/math/smoke/SetPayloadSigTest.h | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/libc/test/src/math/smoke/SetPayloadSigTest.h b/libc/test/src/math/smoke/SetPayloadSigTest.h
index 7ec3ac08a180ab..023a04554d0db1 100644
--- a/libc/test/src/math/smoke/SetPayloadSigTest.h
+++ b/libc/test/src/math/smoke/SetPayloadSigTest.h
@@ -35,7 +35,13 @@ class SetPayloadSigTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
EXPECT_EQ(1, func(&res, T(-1.0)));
EXPECT_EQ(1, func(&res, T(0x42.1p+0)));
EXPECT_EQ(1, func(&res, T(-0x42.1p+0)));
- EXPECT_EQ(1, func(&res, T(StorageType(1) << (FPBits::FRACTION_LEN - 1))));
+
+ FPBits default_snan_payload_bits = FPBits::one();
+ default_snan_payload_bits.set_biased_exponent(FPBits::FRACTION_LEN - 1 +
+ FPBits::EXP_BIAS);
+ T default_snan_payload = default_snan_payload_bits.get_val();
+
+ EXPECT_EQ(1, func(&res, default_snan_payload));
}
void testValidPayloads(SetPayloadSigFunc func) {
>From 6c89a05ebfa7e0616c7d13b793e259078fa0e9f4 Mon Sep 17 00:00:00 2001
From: Job Hernandez <hj93 at protonmail.com>
Date: Thu, 8 Aug 2024 14:03:25 -0700
Subject: [PATCH 2/4] format code
---
libc/test/src/math/smoke/SetPayloadSigTest.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libc/test/src/math/smoke/SetPayloadSigTest.h b/libc/test/src/math/smoke/SetPayloadSigTest.h
index 023a04554d0db1..67eb0d0a0bfaf4 100644
--- a/libc/test/src/math/smoke/SetPayloadSigTest.h
+++ b/libc/test/src/math/smoke/SetPayloadSigTest.h
@@ -40,7 +40,7 @@ class SetPayloadSigTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
default_snan_payload_bits.set_biased_exponent(FPBits::FRACTION_LEN - 1 +
FPBits::EXP_BIAS);
T default_snan_payload = default_snan_payload_bits.get_val();
-
+
EXPECT_EQ(1, func(&res, default_snan_payload));
}
>From 924c032fae9b18314e52ea38aa72f0453de9fe9f Mon Sep 17 00:00:00 2001
From: Job Hernandez <hj93 at protonmail.com>
Date: Thu, 8 Aug 2024 15:06:03 -0700
Subject: [PATCH 3/4] address review
---
libc/test/src/math/smoke/SetPayloadSigTest.h | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/libc/test/src/math/smoke/SetPayloadSigTest.h b/libc/test/src/math/smoke/SetPayloadSigTest.h
index 67eb0d0a0bfaf4..b3a31d30c2bf2a 100644
--- a/libc/test/src/math/smoke/SetPayloadSigTest.h
+++ b/libc/test/src/math/smoke/SetPayloadSigTest.h
@@ -40,7 +40,7 @@ class SetPayloadSigTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
default_snan_payload_bits.set_biased_exponent(FPBits::FRACTION_LEN - 1 +
FPBits::EXP_BIAS);
T default_snan_payload = default_snan_payload_bits.get_val();
-
+
EXPECT_EQ(1, func(&res, default_snan_payload));
}
@@ -61,11 +61,15 @@ class SetPayloadSigTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
EXPECT_TRUE(FPBits(res).is_signaling_nan());
EXPECT_EQ(FPBits::signaling_nan(Sign::POS, 0x123).uintval(),
FPBits(res).uintval());
-
- EXPECT_EQ(0, func(&res, T(FPBits::FRACTION_MASK >> 1)));
+
+ FPBits nan_payload_bits = FPBits::one();
+ nan_payload_bits.set_biased_exponent(FPBits::FRACTION_LEN - 2 +
+ FPBits::EXP_BIAS);
+ T nan_payload = nan_payload_bits.get_val();
+ EXPECT_EQ(0, func(&res, nan_payload));
EXPECT_TRUE(FPBits(res).is_signaling_nan());
EXPECT_EQ(
- FPBits::signaling_nan(Sign::POS, FPBits::FRACTION_MASK >> 1).uintval(),
+ FPBits::signaling_nan(Sign::POS, nan_payload).uintval(),
FPBits(res).uintval());
}
};
>From 98d2080a6d538aef957e0d2cae347301e43f6db7 Mon Sep 17 00:00:00 2001
From: Job Hernandez <hj93 at protonmail.com>
Date: Thu, 8 Aug 2024 15:06:23 -0700
Subject: [PATCH 4/4] format code
---
libc/test/src/math/smoke/SetPayloadSigTest.h | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/libc/test/src/math/smoke/SetPayloadSigTest.h b/libc/test/src/math/smoke/SetPayloadSigTest.h
index b3a31d30c2bf2a..34fe7d351bc7fe 100644
--- a/libc/test/src/math/smoke/SetPayloadSigTest.h
+++ b/libc/test/src/math/smoke/SetPayloadSigTest.h
@@ -40,7 +40,7 @@ class SetPayloadSigTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
default_snan_payload_bits.set_biased_exponent(FPBits::FRACTION_LEN - 1 +
FPBits::EXP_BIAS);
T default_snan_payload = default_snan_payload_bits.get_val();
-
+
EXPECT_EQ(1, func(&res, default_snan_payload));
}
@@ -61,16 +61,15 @@ class SetPayloadSigTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
EXPECT_TRUE(FPBits(res).is_signaling_nan());
EXPECT_EQ(FPBits::signaling_nan(Sign::POS, 0x123).uintval(),
FPBits(res).uintval());
-
+
FPBits nan_payload_bits = FPBits::one();
nan_payload_bits.set_biased_exponent(FPBits::FRACTION_LEN - 2 +
FPBits::EXP_BIAS);
T nan_payload = nan_payload_bits.get_val();
EXPECT_EQ(0, func(&res, nan_payload));
EXPECT_TRUE(FPBits(res).is_signaling_nan());
- EXPECT_EQ(
- FPBits::signaling_nan(Sign::POS, nan_payload).uintval(),
- FPBits(res).uintval());
+ EXPECT_EQ(FPBits::signaling_nan(Sign::POS, nan_payload).uintval(),
+ FPBits(res).uintval());
}
};
More information about the libc-commits
mailing list