[libc-commits] [libc] [libc] Fix build breaks caused by f16sqrtf changes (PR #95459)

via libc-commits libc-commits at lists.llvm.org
Thu Jun 13 12:38:46 PDT 2024


https://github.com/overmighty created https://github.com/llvm/llvm-project/pull/95459

None

>From 4725082f084ea9316b544b262564ac47d188062e Mon Sep 17 00:00:00 2001
From: OverMighty <its.overmighty at gmail.com>
Date: Thu, 13 Jun 2024 21:31:40 +0200
Subject: [PATCH 1/2] [libc] Fix missing OutType template param in calls to
 fputil::sqrt

---
 libc/test/src/stdfix/ISqrtTest.h | 2 +-
 libc/test/src/stdfix/SqrtTest.h  | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/libc/test/src/stdfix/ISqrtTest.h b/libc/test/src/stdfix/ISqrtTest.h
index ddf292fdd083f..692488b383551 100644
--- a/libc/test/src/stdfix/ISqrtTest.h
+++ b/libc/test/src/stdfix/ISqrtTest.h
@@ -55,7 +55,7 @@ template <typename T> class ISqrtTest : public LIBC_NAMESPACE::testing::Test {
       x_d += 1.0;
       ++x;
       OutType result = func(x);
-      double expected = LIBC_NAMESPACE::fputil::sqrt(x_d);
+      double expected = LIBC_NAMESPACE::fputil::sqrt<double>(x_d);
       testSpecificInput(x, result, expected, ERR);
     }
   }
diff --git a/libc/test/src/stdfix/SqrtTest.h b/libc/test/src/stdfix/SqrtTest.h
index 47ec129fab2ae..2a8a825abb460 100644
--- a/libc/test/src/stdfix/SqrtTest.h
+++ b/libc/test/src/stdfix/SqrtTest.h
@@ -49,7 +49,8 @@ template <typename T> class SqrtTest : public LIBC_NAMESPACE::testing::Test {
       T v = LIBC_NAMESPACE::cpp::bit_cast<T>(x);
       double v_d = static_cast<double>(v);
       double errors = LIBC_NAMESPACE::fputil::abs(
-          static_cast<double>(func(v)) - LIBC_NAMESPACE::fputil::sqrt(v_d));
+          static_cast<double>(func(v)) -
+          LIBC_NAMESPACE::fputil::sqrt<double>(v_d));
       if (errors > ERR) {
         // Print out the failure input and output.
         EXPECT_EQ(v, zero);

>From 21a4136915814a17cd304a2c256b9ed610bd83f9 Mon Sep 17 00:00:00 2001
From: OverMighty <its.overmighty at gmail.com>
Date: Thu, 13 Jun 2024 21:34:45 +0200
Subject: [PATCH 2/2] [libc][math] Fix generic_sqrtf128_test being enabled
 without float128 support

---
 libc/test/src/math/smoke/CMakeLists.txt | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index 3bb87d2b0d0f3..3e9edc51b004f 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -2597,6 +2597,9 @@ add_fp_unittest(
   HDRS
     SqrtTest.h
   DEPENDS
+    # The dependency on sqrtf128 is used to disable the test when float128
+    # support is not available.
+    libc.src.math.sqrtf128
     libc.src.__support.FPUtil.generic.sqrt
   COMPILE_OPTIONS
     -O3



More information about the libc-commits mailing list