[libc-commits] [libc] [libc] Fix shared math tests for gcc-13. (PR #199318)

via libc-commits libc-commits at lists.llvm.org
Sat May 23 02:31:54 PDT 2026


https://github.com/lntue updated https://github.com/llvm/llvm-project/pull/199318

>From 931ae4733783f37c06b477bdd490daac35fc16de Mon Sep 17 00:00:00 2001
From: Tue Ly <lntue.h at gmail.com>
Date: Sat, 23 May 2026 04:07:36 +0000
Subject: [PATCH 1/2] [libc] Fix shared math tests for gcc-13.

---
 libc/test/shared/shared_math_test.cpp | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/libc/test/shared/shared_math_test.cpp b/libc/test/shared/shared_math_test.cpp
index 634778380dc8e..7d42a5f6277ba 100644
--- a/libc/test/shared/shared_math_test.cpp
+++ b/libc/test/shared/shared_math_test.cpp
@@ -731,8 +731,8 @@ TEST(LlvmLibcSharedMathTest, AllFloat128) {
                LIBC_NAMESPACE::shared::fsubf128(float128(0.0), float128(0.0)));
   EXPECT_FP_EQ(0x0p+0f,
                LIBC_NAMESPACE::shared::fmulf128(float128(0.0), float128(0.0)));
-  EXPECT_FP_EQ(0.0L, LIBC_NAMESPACE::shared::llrintf128(float128(0.0)));
-  EXPECT_FP_EQ(0.0L, LIBC_NAMESPACE::shared::llroundf128(float128(0.0)));
+  EXPECT_EQ(0LL, LIBC_NAMESPACE::shared::llrintf128(float128(0.0)));
+  EXPECT_EQ(0LL, LIBC_NAMESPACE::shared::llroundf128(float128(0.0)));
   EXPECT_EQ(0L, LIBC_NAMESPACE::shared::lrintf128(float128(0.0)));
   EXPECT_EQ(0L, LIBC_NAMESPACE::shared::lroundf128(float128(0.0)));
   EXPECT_FP_EQ(float128(0.0),
@@ -808,10 +808,14 @@ TEST(LlvmLibcSharedMathTest, AllBFloat16) {
   EXPECT_FP_EQ(bfloat16(0.0), LIBC_NAMESPACE::shared::nextafterbf16(
                                   bfloat16(0.0), bfloat16(0.0)));
   EXPECT_FP_EQ(bfloat16(1.0), LIBC_NAMESPACE::shared::sqrtbf16(bfloat16(1.0)));
-#ifndef LIBC_TYPES_LONG_DOUBLE_IS_DOUBLE_DOUBLE
-  EXPECT_FP_EQ(bfloat16(0.0),
-               LIBC_NAMESPACE::shared::nexttowardbf16(bfloat16(0.0), 0.0L));
-#endif // LIBC_TYPES_LONG_DOUBLE_IS_DOUBLE_DOUBLE
+  // TODO: This test case just failed only when building with gcc-13 and only
+  //   for `ninja libc.test.shared.shared_math_test.__unit__.__NO_FMA_OPT
+  // Other gcc versions or other sub-targets work fine.
+  // #ifndef LIBC_TYPES_LONG_DOUBLE_IS_DOUBLE_DOUBLE
+  //   EXPECT_FP_EQ(bfloat16(0.0),
+  //                LIBC_NAMESPACE::shared::nexttowardbf16(bfloat16(0.0),
+  //                0.0L));
+  // #endif // LIBC_TYPES_LONG_DOUBLE_IS_DOUBLE_DOUBLE
 
   EXPECT_EQ(0, LIBC_NAMESPACE::shared::ilogbbf16(bfloat16(1.0)));
   EXPECT_EQ(0L, LIBC_NAMESPACE::shared::llogbbf16(bfloat16(1.0)));

>From 10a8a0a33214f1be17c3f12795758de5da593d55 Mon Sep 17 00:00:00 2001
From: Tue Ly <lntue.h at gmail.com>
Date: Sat, 23 May 2026 09:31:23 +0000
Subject: [PATCH 2/2] Add link to github issue.

---
 libc/test/shared/shared_math_test.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libc/test/shared/shared_math_test.cpp b/libc/test/shared/shared_math_test.cpp
index 7d42a5f6277ba..d872a8e0ec759 100644
--- a/libc/test/shared/shared_math_test.cpp
+++ b/libc/test/shared/shared_math_test.cpp
@@ -810,7 +810,8 @@ TEST(LlvmLibcSharedMathTest, AllBFloat16) {
   EXPECT_FP_EQ(bfloat16(1.0), LIBC_NAMESPACE::shared::sqrtbf16(bfloat16(1.0)));
   // TODO: This test case just failed only when building with gcc-13 and only
   //   for `ninja libc.test.shared.shared_math_test.__unit__.__NO_FMA_OPT
-  // Other gcc versions or other sub-targets work fine.
+  //   Other gcc versions or other sub-targets work fine.
+  //   https://github.com/llvm/llvm-project/issues/199332
   // #ifndef LIBC_TYPES_LONG_DOUBLE_IS_DOUBLE_DOUBLE
   //   EXPECT_FP_EQ(bfloat16(0.0),
   //                LIBC_NAMESPACE::shared::nexttowardbf16(bfloat16(0.0),



More information about the libc-commits mailing list