Skip to content

[libc][math][c23] Fix setpayloadsig smoke test on RV32 #102538

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
merged 6 commits into from Aug 9, 2024
Merged

[libc][math][c23] Fix setpayloadsig smoke test on RV32 #102538

merged 6 commits into from Aug 9, 2024

Conversation

ghost
Copy link

@ghost ghost commented Aug 8, 2024

No description provided.

Job Hernandez added 2 commits August 8, 2024 14:03
@llvmbot llvmbot added the libc label Aug 8, 2024
@llvmbot
Copy link
Member

llvmbot commented Aug 8, 2024

@llvm/pr-subscribers-libc

Author: Job Henandez Lara (Jobhdez)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/102538.diff

1 Files Affected:

  • (modified) libc/test/src/math/smoke/SetPayloadSigTest.h (+7-1)
diff --git a/libc/test/src/math/smoke/SetPayloadSigTest.h b/libc/test/src/math/smoke/SetPayloadSigTest.h
index 7ec3ac08a180a..67eb0d0a0bfaf 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) {

@ghost
Copy link
Author

ghost commented Aug 8, 2024

@mikhailramalho hello, can you please let me know if this pr fixes the rv32 bug that you mentioned earlier today? thanks. regarding this pr #102413 (comment)

@mikhailramalho
Copy link
Member

The following is still crashing:

/home/mgadelha/tools/llvm-project/libc/test/src/math/smoke/SetPayloadSigTest.h:71:48: error: no viable conversion from 'long double' to 'StorageType' (aka 'BigInt<128U, false, unsigned long long>')
   71 |     EXPECT_EQ(FPBits::signaling_nan(Sign::POS, nan_payload).uintval(),
      |                                                ^~~~~~~~~~~
/home/mgadelha/tools/llvm-project/libc/test/UnitTest/LibcTest.h:420:50: note: expanded from macro 'EXPECT_EQ'
  420 | #define EXPECT_EQ(LHS, RHS) LIBC_TEST_BINOP_(EQ, LHS, RHS, )
      |                                                  ^~~
/home/mgadelha/tools/llvm-project/libc/test/UnitTest/LibcTest.h:413:72: note: expanded from macro 'LIBC_TEST_BINOP_'
  413 |   LIBC_TEST_SCAFFOLDING_(test(LIBC_NAMESPACE::testing::TestCond::COND, LHS,    \
      |                                                                        ^~~
/home/mgadelha/tools/llvm-project/libc/test/UnitTest/LibcTest.h:406:7: note: expanded from macro 'LIBC_TEST_SCAFFOLDING_'
  406 |   if (TEST)                                                                    \
      |       ^~~~
/home/mgadelha/tools/llvm-project/libc/test/src/math/smoke/setpayloadsigf128_test.cpp:13:1: note: in instantiation of member function 'SetPayloadSigTestTemplate<long double>::testValidPayloads' requested here
   13 | LIST_SETPAYLOADSIG_TESTS(float128, LIBC_NAMESPACE::setpayloadsigf128)
      | ^
/home/mgadelha/tools/llvm-project/libc/test/src/math/smoke/SetPayloadSigTest.h:81:54: note: expanded from macro 'LIST_SETPAYLOADSIG_TESTS'
   81 |   TEST_F(LlvmLibcSetPayloadSigTest, ValidPayloads) { testValidPayloads(&func); }
      |                                                      ^
/home/mgadelha/tools/llvm-project/libc/src/__support/big_int.h:362:25: note: candidate constructor not viable: no known conversion from 'long double' to 'const BigInt<128, false> &' for 1st argument
  362 |   LIBC_INLINE constexpr BigInt(const BigInt &other) = default;
      |                         ^      ~~~~~~~~~~~~~~~~~~~
/home/mgadelha/tools/llvm-project/libc/src/__support/big_int.h:365:25: note: candidate template ignored: could not match 'BigInt<OtherBits, OtherSigned, unsigned long long>' against 'long double'
  365 |   LIBC_INLINE constexpr BigInt(
      |                         ^
/home/mgadelha/tools/llvm-project/libc/src/__support/big_int.h:379:45: note: candidate template ignored: could not match 'unsigned long long[N]' against 'long double'
  379 |   template <size_t N> LIBC_INLINE constexpr BigInt(const WordType (&nums)[N]) {
      |                                             ^
/home/mgadelha/tools/llvm-project/libc/src/__support/big_int.h:393:25: note: candidate template ignored: substitution failure [with T = long double]: implicit instantiation of undefined template '__llvm_libc_20_0_0_git::cpp::enable_if<false>'
  393 |   LIBC_INLINE constexpr BigInt(T v) {
      |                         ^
/home/mgadelha/tools/llvm-project/libc/src/__support/big_int.h:385:34: note: explicit constructor is not a candidate
  385 |   LIBC_INLINE constexpr explicit BigInt(
      |                                  ^
/home/mgadelha/tools/llvm-project/libc/src/__support/FPUtil/FPBits.h:394:63: note: passing argument to parameter 'v' here
  394 |                                                   StorageType v = 0) {
      |                                                               ^
1 error generated.

@ghost
Copy link
Author

ghost commented Aug 9, 2024

The following is still crashing:

/home/mgadelha/tools/llvm-project/libc/test/src/math/smoke/SetPayloadSigTest.h:71:48: error: no viable conversion from 'long double' to 'StorageType' (aka 'BigInt<128U, false, unsigned long long>')
   71 |     EXPECT_EQ(FPBits::signaling_nan(Sign::POS, nan_payload).uintval(),
      |                                                ^~~~~~~~~~~
/home/mgadelha/tools/llvm-project/libc/test/UnitTest/LibcTest.h:420:50: note: expanded from macro 'EXPECT_EQ'
  420 | #define EXPECT_EQ(LHS, RHS) LIBC_TEST_BINOP_(EQ, LHS, RHS, )
      |                                                  ^~~
/home/mgadelha/tools/llvm-project/libc/test/UnitTest/LibcTest.h:413:72: note: expanded from macro 'LIBC_TEST_BINOP_'
  413 |   LIBC_TEST_SCAFFOLDING_(test(LIBC_NAMESPACE::testing::TestCond::COND, LHS,    \
      |                                                                        ^~~
/home/mgadelha/tools/llvm-project/libc/test/UnitTest/LibcTest.h:406:7: note: expanded from macro 'LIBC_TEST_SCAFFOLDING_'
  406 |   if (TEST)                                                                    \
      |       ^~~~
/home/mgadelha/tools/llvm-project/libc/test/src/math/smoke/setpayloadsigf128_test.cpp:13:1: note: in instantiation of member function 'SetPayloadSigTestTemplate<long double>::testValidPayloads' requested here
   13 | LIST_SETPAYLOADSIG_TESTS(float128, LIBC_NAMESPACE::setpayloadsigf128)
      | ^
/home/mgadelha/tools/llvm-project/libc/test/src/math/smoke/SetPayloadSigTest.h:81:54: note: expanded from macro 'LIST_SETPAYLOADSIG_TESTS'
   81 |   TEST_F(LlvmLibcSetPayloadSigTest, ValidPayloads) { testValidPayloads(&func); }
      |                                                      ^
/home/mgadelha/tools/llvm-project/libc/src/__support/big_int.h:362:25: note: candidate constructor not viable: no known conversion from 'long double' to 'const BigInt<128, false> &' for 1st argument
  362 |   LIBC_INLINE constexpr BigInt(const BigInt &other) = default;
      |                         ^      ~~~~~~~~~~~~~~~~~~~
/home/mgadelha/tools/llvm-project/libc/src/__support/big_int.h:365:25: note: candidate template ignored: could not match 'BigInt<OtherBits, OtherSigned, unsigned long long>' against 'long double'
  365 |   LIBC_INLINE constexpr BigInt(
      |                         ^
/home/mgadelha/tools/llvm-project/libc/src/__support/big_int.h:379:45: note: candidate template ignored: could not match 'unsigned long long[N]' against 'long double'
  379 |   template <size_t N> LIBC_INLINE constexpr BigInt(const WordType (&nums)[N]) {
      |                                             ^
/home/mgadelha/tools/llvm-project/libc/src/__support/big_int.h:393:25: note: candidate template ignored: substitution failure [with T = long double]: implicit instantiation of undefined template '__llvm_libc_20_0_0_git::cpp::enable_if<false>'
  393 |   LIBC_INLINE constexpr BigInt(T v) {
      |                         ^
/home/mgadelha/tools/llvm-project/libc/src/__support/big_int.h:385:34: note: explicit constructor is not a candidate
  385 |   LIBC_INLINE constexpr explicit BigInt(
      |                                  ^
/home/mgadelha/tools/llvm-project/libc/src/__support/FPUtil/FPBits.h:394:63: note: passing argument to parameter 'v' here
  394 |                                                   StorageType v = 0) {
      |                                                               ^
1 error generated.

Ok I will address it. I’ll tag you when I change it.

Copy link

github-actions bot commented Aug 9, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

Copy link
Member

@mikhailramalho mikhailramalho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the fix!

@ghost
Copy link
Author

ghost commented Aug 9, 2024

thanks for the fix!

No problem

@mikhailramalho mikhailramalho merged commit 9788368 into llvm:main Aug 9, 2024
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants