-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[libc] Fix canonicalize[f|l] tests for targets with long-double-is-double. #115998
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Member
|
@llvm/pr-subscribers-libc Author: None (lntue) ChangesFull diff: https://github.com/llvm/llvm-project/pull/115998.diff 1 Files Affected:
diff --git a/libc/test/src/math/smoke/CanonicalizeTest.h b/libc/test/src/math/smoke/CanonicalizeTest.h
index f22a282b1843b6..ef75f568b8275b 100644
--- a/libc/test/src/math/smoke/CanonicalizeTest.h
+++ b/libc/test/src/math/smoke/CanonicalizeTest.h
@@ -18,10 +18,6 @@
#include "hdr/math_macros.h"
-#if __SIZEOF_LONG_DOUBLE__ != 16 && __SIZEOF_LONG_DOUBLE__ != 12
-#error "unhandled long double type"
-#endif
-
#define TEST_SPECIAL(x, y, expected, expected_exception) \
EXPECT_EQ(expected, f(&x, &y)); \
EXPECT_FP_EXCEPTION(expected_exception); \
@@ -66,10 +62,10 @@ class CanonicalizeTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
// Exponent | Significand | Meaning
// | Bits 63-62 | Bits 61-0 |
// All Ones | 00 | Zero | Pseudo Infinity, Value = SNaN
-#if __SIZEOF_LONG_DOUBLE__ == 16
- FPBits test1(0x00000000'00007FFF'00000000'00000000_u128);
-#elif __SIZEOF_LONG_DOUBLE__ == 12
+#if __SIZEOF_LONG_DOUBLE__ == 12
FPBits test1(0x00007FFF'00000000'00000000_u96);
+#else
+ FPBits test1(0x00000000'00007FFF'00000000'00000000_u128);
#endif
const T test1_val = test1.get_val();
TEST_SPECIAL(cx, test1_val, 1, FE_INVALID);
@@ -78,37 +74,37 @@ class CanonicalizeTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
// Exponent | Significand | Meaning
// | Bits 63-62 | Bits 61-0 |
// All Ones | 00 | Non-Zero | Pseudo NaN, Value = SNaN
-#if __SIZEOF_LONG_DOUBLE__ == 16
- FPBits test2_1(0x00000000'00007FFF'00000000'00000001_u128);
-#elif __SIZEOF_LONG_DOUBLE__ == 12
+#if __SIZEOF_LONG_DOUBLE__ == 12
FPBits test2_1(0x00007FFF'00000000'00000001_u96);
+#else
+ FPBits test2_1(0x00000000'00007FFF'00000000'00000001_u128);
#endif
const T test2_1_val = test2_1.get_val();
TEST_SPECIAL(cx, test2_1_val, 1, FE_INVALID);
EXPECT_FP_EQ(cx, aNaN);
-#if __SIZEOF_LONG_DOUBLE__ == 16
- FPBits test2_2(0x00000000'00007FFF'00000042'70000001_u128);
-#elif __SIZEOF_LONG_DOUBLE__ == 12
+#if __SIZEOF_LONG_DOUBLE__ == 12
FPBits test2_2(0x00007FFF'00000042'70000001_u96);
+#else
+ FPBits test2_2(0x00000000'00007FFF'00000042'70000001_u128);
#endif
const T test2_2_val = test2_2.get_val();
TEST_SPECIAL(cx, test2_2_val, 1, FE_INVALID);
EXPECT_FP_EQ(cx, aNaN);
-#if __SIZEOF_LONG_DOUBLE__ == 16
- FPBits test2_3(0x00000000'00007FFF'00000000'08261001_u128);
-#elif __SIZEOF_LONG_DOUBLE__ == 12
+#if __SIZEOF_LONG_DOUBLE__ == 12
FPBits test2_3(0x00007FFF'00000000'08261001_u96);
+#else
+ FPBits test2_3(0x00000000'00007FFF'00000000'08261001_u128);
#endif
const T test2_3_val = test2_3.get_val();
TEST_SPECIAL(cx, test2_3_val, 1, FE_INVALID);
EXPECT_FP_EQ(cx, aNaN);
-#if __SIZEOF_LONG_DOUBLE__ == 16
- FPBits test2_4(0x00000000'00007FFF'00007800'08261001_u128);
-#elif __SIZEOF_LONG_DOUBLE__ == 12
+#if __SIZEOF_LONG_DOUBLE__ == 12
FPBits test2_4(0x00007FFF'00007800'08261001_u96);
+#else
+ FPBits test2_4(0x00000000'00007FFF'00007800'08261001_u128);
#endif
const T test2_4_val = test2_4.get_val();
TEST_SPECIAL(cx, test2_4_val, 1, FE_INVALID);
@@ -117,37 +113,37 @@ class CanonicalizeTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
// Exponent | Significand | Meaning
// | Bits 63-62 | Bits 61-0 |
// All Ones | 01 | Anything | Pseudo NaN, Value = SNaN
-#if __SIZEOF_LONG_DOUBLE__ == 16
- FPBits test3_1(0x00000000'00007FFF'40000000'00000000_u128);
-#elif __SIZEOF_LONG_DOUBLE__ == 12
+#if __SIZEOF_LONG_DOUBLE__ == 12
FPBits test3_1(0x00007FFF'40000000'00000000_u96);
+#else
+ FPBits test3_1(0x00000000'00007FFF'40000000'00000000_u128);
#endif
const T test3_1_val = test3_1.get_val();
TEST_SPECIAL(cx, test3_1_val, 1, FE_INVALID);
EXPECT_FP_EQ(cx, aNaN);
-#if __SIZEOF_LONG_DOUBLE__ == 16
- FPBits test3_2(0x00000000'00007FFF'40000042'70000001_u128);
-#elif __SIZEOF_LONG_DOUBLE__ == 12
+#if __SIZEOF_LONG_DOUBLE__ == 12
FPBits test3_2(0x00007FFF'40000042'70000001_u96);
+#else
+ FPBits test3_2(0x00000000'00007FFF'40000042'70000001_u128);
#endif
const T test3_2_val = test3_2.get_val();
TEST_SPECIAL(cx, test3_2_val, 1, FE_INVALID);
EXPECT_FP_EQ(cx, aNaN);
-#if __SIZEOF_LONG_DOUBLE__ == 16
- FPBits test3_3(0x00000000'00007FFF'40000000'08261001_u128);
-#elif __SIZEOF_LONG_DOUBLE__ == 12
+#if __SIZEOF_LONG_DOUBLE__ == 12
FPBits test3_3(0x00007FFF'40000000'08261001_u96);
+#else
+ FPBits test3_3(0x00000000'00007FFF'40000000'08261001_u128);
#endif
const T test3_3_val = test3_3.get_val();
TEST_SPECIAL(cx, test3_3_val, 1, FE_INVALID);
EXPECT_FP_EQ(cx, aNaN);
-#if __SIZEOF_LONG_DOUBLE__ == 16
- FPBits test3_4(0x00000000'00007FFF'40007800'08261001_u128);
-#elif __SIZEOF_LONG_DOUBLE__ == 12
+#if __SIZEOF_LONG_DOUBLE__ == 12
FPBits test3_4(0x00007FFF'40007800'08261001_u96);
+#else
+ FPBits test3_4(0x00000000'00007FFF'40007800'08261001_u128);
#endif
const T test3_4_val = test3_4.get_val();
TEST_SPECIAL(cx, test3_4_val, 1, FE_INVALID);
@@ -157,30 +153,30 @@ class CanonicalizeTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
// | Bit 63 | Bits 62-0 |
// All zeroes | One | Anything | Pseudo Denormal, Value =
// | | | (−1)**s × m × 2**−16382
-#if __SIZEOF_LONG_DOUBLE__ == 16
- FPBits test4_1(0x00000000'00000000'80000000'00000000_u128);
-#elif __SIZEOF_LONG_DOUBLE__ == 12
+#if __SIZEOF_LONG_DOUBLE__ == 12
FPBits test4_1(0x00000000'80000000'00000000_u96);
+#else
+ FPBits test4_1(0x00000000'00000000'80000000'00000000_u128);
#endif
const T test4_1_val = test4_1.get_val();
TEST_SPECIAL(cx, test4_1_val, 0, 0);
EXPECT_FP_EQ(
cx, FPBits::make_value(test4_1.get_explicit_mantissa(), 0).get_val());
-#if __SIZEOF_LONG_DOUBLE__ == 16
- FPBits test4_2(0x00000000'00000000'80000042'70000001_u128);
-#elif __SIZEOF_LONG_DOUBLE__ == 12
+#if __SIZEOF_LONG_DOUBLE__ == 12
FPBits test4_2(0x00000000'80000042'70000001_u96);
+#else
+ FPBits test4_2(0x00000000'00000000'80000042'70000001_u128);
#endif
const T test4_2_val = test4_2.get_val();
TEST_SPECIAL(cx, test4_2_val, 0, 0);
EXPECT_FP_EQ(
cx, FPBits::make_value(test4_2.get_explicit_mantissa(), 0).get_val());
-#if __SIZEOF_LONG_DOUBLE__ == 16
- FPBits test4_3(0x00000000'00000000'80000000'08261001_u128);
-#elif __SIZEOF_LONG_DOUBLE__ == 12
+#if __SIZEOF_LONG_DOUBLE__ == 12
FPBits test4_3(0x00000000'80000000'08261001_u96);
+#else
+ FPBits test4_3(0x00000000'00000000'80000000'08261001_u128);
#endif
const T test4_3_val = test4_3.get_val();
TEST_SPECIAL(cx, test4_3_val, 0, 0);
@@ -191,55 +187,55 @@ class CanonicalizeTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
// | Bit 63 | Bits 62-0 |
// All Other | Zero | Anything | Unnormal, Value = SNaN
// Values | | |
-#if __SIZEOF_LONG_DOUBLE__ == 16
- FPBits test5_1(0x00000000'00000040'00000000'00000001_u128);
-#elif __SIZEOF_LONG_DOUBLE__ == 12
+#if __SIZEOF_LONG_DOUBLE__ == 12
FPBits test5_1(0x00000040'00000000'00000001_u96);
+#else
+ FPBits test5_1(0x00000000'00000040'00000000'00000001_u128);
#endif
const T test5_1_val = test5_1.get_val();
TEST_SPECIAL(cx, test5_1_val, 1, FE_INVALID);
EXPECT_FP_EQ(cx, aNaN);
-#if __SIZEOF_LONG_DOUBLE__ == 16
- FPBits test5_2(0x00000000'00000230'00000042'70000001_u128);
-#elif __SIZEOF_LONG_DOUBLE__ == 12
+#if __SIZEOF_LONG_DOUBLE__ == 12
FPBits test5_2(0x00000230'00000042'70000001_u96);
+#else
+ FPBits test5_2(0x00000000'00000230'00000042'70000001_u128);
#endif
const T test5_2_val = test5_2.get_val();
TEST_SPECIAL(cx, test5_2_val, 1, FE_INVALID);
EXPECT_FP_EQ(cx, aNaN);
-#if __SIZEOF_LONG_DOUBLE__ == 16
- FPBits test5_3(0x00000000'00000560'00000000'08261001_u128);
-#elif __SIZEOF_LONG_DOUBLE__ == 12
+#if __SIZEOF_LONG_DOUBLE__ == 12
FPBits test5_3(0x00000560'00000000'08261001_u96);
+#else
+ FPBits test5_3(0x00000000'00000560'00000000'08261001_u128);
#endif
const T test5_3_val = test5_3.get_val();
TEST_SPECIAL(cx, test5_3_val, 1, FE_INVALID);
EXPECT_FP_EQ(cx, aNaN);
-#if __SIZEOF_LONG_DOUBLE__ == 16
- FPBits test5_4(0x00000000'00000780'00000028'16000000_u128);
-#elif __SIZEOF_LONG_DOUBLE__ == 12
+#if __SIZEOF_LONG_DOUBLE__ == 12
FPBits test5_4(0x00000780'00000028'16000000_u96);
+#else
+ FPBits test5_4(0x00000000'00000780'00000028'16000000_u128);
#endif
const T test5_4_val = test5_4.get_val();
TEST_SPECIAL(cx, test5_4_val, 1, FE_INVALID);
EXPECT_FP_EQ(cx, aNaN);
-#if __SIZEOF_LONG_DOUBLE__ == 16
- FPBits test5_5(0x00000000'00000900'00000042'70000001_u128);
-#elif __SIZEOF_LONG_DOUBLE__ == 12
+#if __SIZEOF_LONG_DOUBLE__ == 12
FPBits test5_5(0x00000900'00000042'70000001_u96);
+#else
+ FPBits test5_5(0x00000000'00000900'00000042'70000001_u128);
#endif
const T test5_5_val = test5_5.get_val();
TEST_SPECIAL(cx, test5_5_val, 1, FE_INVALID);
EXPECT_FP_EQ(cx, aNaN);
-#if __SIZEOF_LONG_DOUBLE__ == 16
- FPBits test5_6(0x00000000'00000AB0'00000000'08261001_u128);
-#elif __SIZEOF_LONG_DOUBLE__ == 12
+#if __SIZEOF_LONG_DOUBLE__ == 12
FPBits test5_6(0x00000AB0'00000000'08261001_u96);
+#else
+ FPBits test5_6(0x00000000'00000AB0'00000000'08261001_u128);
#endif
const T test5_6_val = test5_6.get_val();
TEST_SPECIAL(cx, test5_6_val, 1, FE_INVALID);
|
jhuber6
approved these changes
Nov 13, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.