Skip to content

Conversation

@lntue
Copy link
Contributor

@lntue lntue commented Oct 21, 2025

No description provided.

@llvmbot
Copy link
Member

llvmbot commented Oct 21, 2025

@llvm/pr-subscribers-libc

Author: None (lntue)

Changes

Patch is 95.67 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/164522.diff

57 Files Affected:

  • (modified) libc/src/__support/math/atan2f.h (+3-1)
  • (modified) libc/test/UnitTest/FPMatcher.h (+29-24)
  • (modified) libc/test/src/math/acos_test.cpp (+8-1)
  • (modified) libc/test/src/math/acosf16_test.cpp (+9-2)
  • (modified) libc/test/src/math/acosf_test.cpp (+9-2)
  • (modified) libc/test/src/math/acoshf_test.cpp (+8-1)
  • (modified) libc/test/src/math/asin_test.cpp (+10-1)
  • (modified) libc/test/src/math/asinf_test.cpp (+9-2)
  • (modified) libc/test/src/math/asinhf16_test.cpp (+11-2)
  • (modified) libc/test/src/math/asinhf_test.cpp (+9-2)
  • (modified) libc/test/src/math/atan2f_test.cpp (+15-4)
  • (modified) libc/test/src/math/atanf16_test.cpp (+9-2)
  • (modified) libc/test/src/math/cbrt_test.cpp (+10-3)
  • (modified) libc/test/src/math/cos_test.cpp (+8-1)
  • (modified) libc/test/src/math/cosf16_test.cpp (+9-2)
  • (modified) libc/test/src/math/cosf_test.cpp (+17-7)
  • (modified) libc/test/src/math/coshf16_test.cpp (+9-2)
  • (modified) libc/test/src/math/erff_test.cpp (+12-6)
  • (modified) libc/test/src/math/exp10_test.cpp (+12-6)
  • (modified) libc/test/src/math/exp10f16_test.cpp (+11-2)
  • (modified) libc/test/src/math/exp10m1f16_test.cpp (+11-2)
  • (modified) libc/test/src/math/exp10m1f_test.cpp (+9-2)
  • (modified) libc/test/src/math/exp2_test.cpp (+3-3)
  • (modified) libc/test/src/math/exp2f16_test.cpp (+9-2)
  • (modified) libc/test/src/math/exp2f_test.cpp (+8-2)
  • (modified) libc/test/src/math/exp2m1f16_test.cpp (+11-2)
  • (modified) libc/test/src/math/exp2m1f_test.cpp (+8-2)
  • (modified) libc/test/src/math/exp_test.cpp (+12-6)
  • (modified) libc/test/src/math/expf16_test.cpp (+9-2)
  • (modified) libc/test/src/math/expf_test.cpp (+8-2)
  • (modified) libc/test/src/math/expm1_test.cpp (+9-3)
  • (modified) libc/test/src/math/expm1f16_test.cpp (+11-2)
  • (modified) libc/test/src/math/expm1f_test.cpp (+9-3)
  • (modified) libc/test/src/math/log10_test.cpp (+11-5)
  • (modified) libc/test/src/math/log10f16_test.cpp (+11-2)
  • (modified) libc/test/src/math/log10f_test.cpp (+8-2)
  • (modified) libc/test/src/math/log1p_test.cpp (+12-7)
  • (modified) libc/test/src/math/log1pf_test.cpp (+8-2)
  • (modified) libc/test/src/math/log2_test.cpp (+3-3)
  • (modified) libc/test/src/math/log2f16_test.cpp (+8-2)
  • (modified) libc/test/src/math/log_test.cpp (+11-5)
  • (modified) libc/test/src/math/logf16_test.cpp (+9-2)
  • (modified) libc/test/src/math/logf_test.cpp (+12-2)
  • (modified) libc/test/src/math/powf_test.cpp (+10-3)
  • (modified) libc/test/src/math/sin_test.cpp (+8-1)
  • (modified) libc/test/src/math/sincos_test.cpp (+15-8)
  • (modified) libc/test/src/math/sincosf_test.cpp (+15-9)
  • (modified) libc/test/src/math/sinf16_test.cpp (+9-2)
  • (modified) libc/test/src/math/sinf_test.cpp (+23-13)
  • (modified) libc/test/src/math/sinhf16_test.cpp (+9-2)
  • (modified) libc/test/src/math/sinhf_test.cpp (+9-3)
  • (modified) libc/test/src/math/smoke/sinf_test.cpp (+6)
  • (modified) libc/test/src/math/tan_test.cpp (+10-3)
  • (modified) libc/test/src/math/tanf16_test.cpp (+9-2)
  • (modified) libc/test/src/math/tanf_test.cpp (+9-2)
  • (modified) libc/test/src/math/tanhf16_test.cpp (+9-2)
  • (modified) libc/test/src/math/tanpif16_test.cpp (+11-2)
diff --git a/libc/src/__support/math/atan2f.h b/libc/src/__support/math/atan2f.h
index e3b19329126f4..0133d12c1e071 100644
--- a/libc/src/__support/math/atan2f.h
+++ b/libc/src/__support/math/atan2f.h
@@ -18,9 +18,11 @@
 #include "src/__support/FPUtil/nearest_integer.h"
 #include "src/__support/macros/config.h"
 #include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
+#include "src/__support/macros/properties/cpu_features.h" // LIBC_TARGET_CPU_HAS_FMA
 
 #if defined(LIBC_MATH_HAS_SKIP_ACCURATE_PASS) &&                               \
-    defined(LIBC_MATH_HAS_INTERMEDIATE_COMP_IN_FLOAT)
+    defined(LIBC_MATH_HAS_INTERMEDIATE_COMP_IN_FLOAT) &&                       \
+    defined(LIBC_TARGET_CPU_HAS_FMA_FLOAT)
 
 // We use float-float implementation to reduce size.
 #include "atan2f_float.h"
diff --git a/libc/test/UnitTest/FPMatcher.h b/libc/test/UnitTest/FPMatcher.h
index f74276f54eb25..430727e537107 100644
--- a/libc/test/UnitTest/FPMatcher.h
+++ b/libc/test/UnitTest/FPMatcher.h
@@ -16,6 +16,7 @@
 #include "src/__support/FPUtil/fpbits_str.h"
 #include "src/__support/libc_errno.h"
 #include "src/__support/macros/config.h"
+#include "src/__support/macros/optimization.h"
 #include "src/__support/macros/properties/architectures.h"
 #include "test/UnitTest/ErrnoCheckingTest.h"
 #include "test/UnitTest/RoundingModeUtils.h"
@@ -294,42 +295,46 @@ struct ModifyMXCSR {
 
 #define EXPECT_MATH_ERRNO(expected)                                            \
   do {                                                                         \
-    if (math_errhandling & MATH_ERRNO) {                                       \
-      int actual = libc_errno;                                                 \
-      libc_errno = 0;                                                          \
-      EXPECT_EQ(actual, expected);                                             \
-    }                                                                          \
+    if ((LIBC_MATH & LIBC_MATH_NO_ERRNO) == 0)                                 \
+      if (math_errhandling & MATH_ERRNO) {                                     \
+        int actual = libc_errno;                                               \
+        libc_errno = 0;                                                        \
+        EXPECT_EQ(actual, expected);                                           \
+      }                                                                        \
   } while (0)
 
 #define ASSERT_MATH_ERRNO(expected)                                            \
   do {                                                                         \
-    if (math_errhandling & MATH_ERRNO) {                                       \
-      int actual = libc_errno;                                                 \
-      libc_errno = 0;                                                          \
-      ASSERT_EQ(actual, expected);                                             \
-    }                                                                          \
+    if ((LIBC_MATH & LIBC_MATH_NO_ERRNO) == 0)                                 \
+      if (math_errhandling & MATH_ERRNO) {                                     \
+        int actual = libc_errno;                                               \
+        libc_errno = 0;                                                        \
+        ASSERT_EQ(actual, expected);                                           \
+      }                                                                        \
   } while (0)
 
 #define EXPECT_FP_EXCEPTION(expected)                                          \
   do {                                                                         \
-    if (math_errhandling & MATH_ERREXCEPT) {                                   \
-      EXPECT_EQ(                                                               \
-          LIBC_NAMESPACE::fputil::test_except(                                 \
-              static_cast<int>(FE_ALL_EXCEPT)) &                               \
-              ((expected) ? (expected) : static_cast<int>(FE_ALL_EXCEPT)),     \
-          (expected));                                                         \
-    }                                                                          \
+    if ((LIBC_MATH & LIBC_MATH_NO_EXCEPT) == 0)                                \
+      if (math_errhandling & MATH_ERREXCEPT) {                                 \
+        EXPECT_EQ(                                                             \
+            LIBC_NAMESPACE::fputil::test_except(                               \
+                static_cast<int>(FE_ALL_EXCEPT)) &                             \
+                ((expected) ? (expected) : static_cast<int>(FE_ALL_EXCEPT)),   \
+            (expected));                                                       \
+      }                                                                        \
   } while (0)
 
 #define ASSERT_FP_EXCEPTION(expected)                                          \
   do {                                                                         \
-    if (math_errhandling & MATH_ERREXCEPT) {                                   \
-      ASSERT_EQ(                                                               \
-          LIBC_NAMESPACE::fputil::test_except(                                 \
-              static_cast<int>(FE_ALL_EXCEPT)) &                               \
-              ((expected) ? (expected) : static_cast<int>(FE_ALL_EXCEPT)),     \
-          (expected));                                                         \
-    }                                                                          \
+    if ((LIBC_MATH & LIBC_MATH_NO_EXCEPT) == 0)                                \
+      if (math_errhandling & MATH_ERREXCEPT) {                                 \
+        ASSERT_EQ(                                                             \
+            LIBC_NAMESPACE::fputil::test_except(                               \
+                static_cast<int>(FE_ALL_EXCEPT)) &                             \
+                ((expected) ? (expected) : static_cast<int>(FE_ALL_EXCEPT)),   \
+            (expected));                                                       \
+      }                                                                        \
   } while (0)
 
 #define EXPECT_FP_EQ_WITH_EXCEPTION(expected_val, actual_val, expected_except) \
diff --git a/libc/test/src/math/acos_test.cpp b/libc/test/src/math/acos_test.cpp
index 140488702f0bc..8678fe620d6d3 100644
--- a/libc/test/src/math/acos_test.cpp
+++ b/libc/test/src/math/acos_test.cpp
@@ -6,11 +6,18 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "src/__support/macros/optimization.h"
 #include "src/math/acos.h"
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
 #include "utils/MPFRWrapper/MPFRUtils.h"
 
+#ifdef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+#define TOLERANCE 8
+#else
+#define TOLERANCE 0
+#endif // LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+
 using LlvmLibcAcosTest = LIBC_NAMESPACE::testing::FPTest<double>;
 
 namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
@@ -46,7 +53,7 @@ TEST_F(LlvmLibcAcosTest, InDoubleRange) {
       ++count;
 
       if (!TEST_MPFR_MATCH_ROUNDING_SILENTLY(mpfr::Operation::Acos, x, result,
-                                             0.5, rounding_mode)) {
+                                             TOLERANCE + 0.5, rounding_mode)) {
         ++fails;
         while (!TEST_MPFR_MATCH_ROUNDING_SILENTLY(mpfr::Operation::Acos, x,
                                                   result, tol, rounding_mode)) {
diff --git a/libc/test/src/math/acosf16_test.cpp b/libc/test/src/math/acosf16_test.cpp
index f4890c81b0bcb..ca33550c6ce92 100644
--- a/libc/test/src/math/acosf16_test.cpp
+++ b/libc/test/src/math/acosf16_test.cpp
@@ -6,11 +6,18 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "src/__support/macros/optimization.h"
 #include "src/math/acosf16.h"
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
 #include "utils/MPFRWrapper/MPFRUtils.h"
 
+#ifdef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+#define TOLERANCE 1
+#else
+#define TOLERANCE 0
+#endif // LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+
 using LlvmLibcAcosf16Test = LIBC_NAMESPACE::testing::FPTest<float16>;
 
 namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
@@ -28,7 +35,7 @@ TEST_F(LlvmLibcAcosf16Test, PositiveRange) {
     float16 x = FPBits(v).get_val();
 
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Acos, x,
-                                   LIBC_NAMESPACE::acosf16(x), 0.5);
+                                   LIBC_NAMESPACE::acosf16(x), TOLERANCE + 0.5);
   }
 }
 
@@ -37,6 +44,6 @@ TEST_F(LlvmLibcAcosf16Test, NegativeRange) {
     float16 x = FPBits(v).get_val();
 
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Acos, x,
-                                   LIBC_NAMESPACE::acosf16(x), 0.5);
+                                   LIBC_NAMESPACE::acosf16(x), TOLERANCE + 0.5);
   }
 }
diff --git a/libc/test/src/math/acosf_test.cpp b/libc/test/src/math/acosf_test.cpp
index 3b45749467b80..40b87021109f9 100644
--- a/libc/test/src/math/acosf_test.cpp
+++ b/libc/test/src/math/acosf_test.cpp
@@ -10,11 +10,18 @@
 #include "hdr/math_macros.h"
 #include "hdr/stdint_proxy.h"
 #include "src/__support/FPUtil/FPBits.h"
+#include "src/__support/macros/optimization.h"
 #include "src/math/acosf.h"
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
 #include "utils/MPFRWrapper/MPFRUtils.h"
 
+#ifdef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+#define TOLERANCE 1
+#else
+#define TOLERANCE 0
+#endif // LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+
 namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
 
 using LlvmLibcAcosfTest = LIBC_NAMESPACE::testing::FPTest<float>;
@@ -72,8 +79,8 @@ TEST_F(LlvmLibcAcosfTest, SpecificBitPatterns) {
   for (int i = 0; i < N; ++i) {
     float x = FPBits(INPUTS[i]).get_val();
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Acos, x,
-                                   LIBC_NAMESPACE::acosf(x), 0.5);
+                                   LIBC_NAMESPACE::acosf(x), TOLERANCE + 0.5);
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Acos, -x,
-                                   LIBC_NAMESPACE::acosf(-x), 0.5);
+                                   LIBC_NAMESPACE::acosf(-x), TOLERANCE + 0.5);
   }
 }
diff --git a/libc/test/src/math/acoshf_test.cpp b/libc/test/src/math/acoshf_test.cpp
index 506f17680887e..a0e9b390b58de 100644
--- a/libc/test/src/math/acoshf_test.cpp
+++ b/libc/test/src/math/acoshf_test.cpp
@@ -10,11 +10,18 @@
 #include "hdr/math_macros.h"
 #include "hdr/stdint_proxy.h"
 #include "src/__support/FPUtil/FPBits.h"
+#include "src/__support/macros/optimization.h"
 #include "src/math/acoshf.h"
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
 #include "utils/MPFRWrapper/MPFRUtils.h"
 
+#ifdef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+#define TOLERANCE 1
+#else
+#define TOLERANCE 0
+#endif // LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+
 using LlvmLibcAcoshfTest = LIBC_NAMESPACE::testing::FPTest<float>;
 
 namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
@@ -68,6 +75,6 @@ TEST_F(LlvmLibcAcoshfTest, SpecificBitPatterns) {
   for (int i = 0; i < N; ++i) {
     float x = FPBits(INPUTS[i]).get_val();
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Acosh, x,
-                                   LIBC_NAMESPACE::acoshf(x), 0.5);
+                                   LIBC_NAMESPACE::acoshf(x), TOLERANCE + 0.5);
   }
 }
diff --git a/libc/test/src/math/asin_test.cpp b/libc/test/src/math/asin_test.cpp
index 03ae963e9f924..4e3638410b484 100644
--- a/libc/test/src/math/asin_test.cpp
+++ b/libc/test/src/math/asin_test.cpp
@@ -6,11 +6,18 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "src/__support/macros/optimization.h"
 #include "src/math/asin.h"
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
 #include "utils/MPFRWrapper/MPFRUtils.h"
 
+#ifdef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+#define TOLERANCE 6
+#else
+#define TOLERANCE 0
+#endif // LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+
 using LlvmLibcAsinTest = LIBC_NAMESPACE::testing::FPTest<double>;
 
 namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
@@ -47,7 +54,7 @@ TEST_F(LlvmLibcAsinTest, InDoubleRange) {
       ++count;
 
       if (!TEST_MPFR_MATCH_ROUNDING_SILENTLY(mpfr::Operation::Asin, x, result,
-                                             0.5, rounding_mode)) {
+                                             TOLERANCE + 0.5, rounding_mode)) {
         ++fails;
         while (!TEST_MPFR_MATCH_ROUNDING_SILENTLY(mpfr::Operation::Asin, x,
                                                   result, tol, rounding_mode)) {
@@ -72,6 +79,7 @@ TEST_F(LlvmLibcAsinTest, InDoubleRange) {
   tlog << " Test Rounding To Nearest...\n";
   test(mpfr::RoundingMode::Nearest);
 
+#ifndef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
   tlog << " Test Rounding Downward...\n";
   test(mpfr::RoundingMode::Downward);
 
@@ -80,4 +88,5 @@ TEST_F(LlvmLibcAsinTest, InDoubleRange) {
 
   tlog << " Test Rounding Toward Zero...\n";
   test(mpfr::RoundingMode::TowardZero);
+#endif // LIBC_MATH_HAS_SKIP_ACCURATE_PASS
 }
diff --git a/libc/test/src/math/asinf_test.cpp b/libc/test/src/math/asinf_test.cpp
index 824bc1ef868af..20702c5c15e88 100644
--- a/libc/test/src/math/asinf_test.cpp
+++ b/libc/test/src/math/asinf_test.cpp
@@ -11,11 +11,18 @@
 #include "hdr/math_macros.h"
 #include "hdr/stdint_proxy.h"
 #include "src/__support/FPUtil/FPBits.h"
+#include "src/__support/macros/optimization.h"
 #include "src/math/asinf.h"
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
 #include "utils/MPFRWrapper/MPFRUtils.h"
 
+#ifdef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+#define TOLERANCE 1
+#else
+#define TOLERANCE 0
+#endif // LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+
 using LlvmLibcAsinfTest = LIBC_NAMESPACE::testing::FPTest<float>;
 
 namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
@@ -68,8 +75,8 @@ TEST_F(LlvmLibcAsinfTest, SpecificBitPatterns) {
   for (int i = 0; i < N; ++i) {
     float x = FPBits(INPUTS[i]).get_val();
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Asin, x,
-                                   LIBC_NAMESPACE::asinf(x), 0.5);
+                                   LIBC_NAMESPACE::asinf(x), TOLERANCE + 0.5);
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Asin, -x,
-                                   LIBC_NAMESPACE::asinf(-x), 0.5);
+                                   LIBC_NAMESPACE::asinf(-x), TOLERANCE + 0.5);
   }
 }
diff --git a/libc/test/src/math/asinhf16_test.cpp b/libc/test/src/math/asinhf16_test.cpp
index 929d13713d197..8d0f754a0645b 100644
--- a/libc/test/src/math/asinhf16_test.cpp
+++ b/libc/test/src/math/asinhf16_test.cpp
@@ -6,11 +6,18 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "src/__support/macros/optimization.h"
 #include "src/math/asinhf16.h"
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
 #include "utils/MPFRWrapper/MPFRUtils.h"
 
+#ifdef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+#define TOLERANCE 1
+#else
+#define TOLERANCE 0
+#endif // LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+
 using LlvmLibcAsinhf16Test = LIBC_NAMESPACE::testing::FPTest<float16>;
 
 namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
@@ -28,7 +35,8 @@ TEST_F(LlvmLibcAsinhf16Test, PositiveRange) {
     float16 x = FPBits(v).get_val();
 
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Asinh, x,
-                                   LIBC_NAMESPACE::asinhf16(x), 0.5);
+                                   LIBC_NAMESPACE::asinhf16(x),
+                                   TOLERANCE + 0.5);
   }
 }
 
@@ -37,6 +45,7 @@ TEST_F(LlvmLibcAsinhf16Test, NegativeRange) {
     float16 x = FPBits(v).get_val();
 
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Asinh, x,
-                                   LIBC_NAMESPACE::asinhf16(x), 0.5);
+                                   LIBC_NAMESPACE::asinhf16(x),
+                                   TOLERANCE + 0.5);
   }
 }
diff --git a/libc/test/src/math/asinhf_test.cpp b/libc/test/src/math/asinhf_test.cpp
index 4681aad03187d..9d9c042208d28 100644
--- a/libc/test/src/math/asinhf_test.cpp
+++ b/libc/test/src/math/asinhf_test.cpp
@@ -9,11 +9,18 @@
 #include "hdr/math_macros.h"
 #include "hdr/stdint_proxy.h"
 #include "src/__support/FPUtil/FPBits.h"
+#include "src/__support/macros/optimization.h"
 #include "src/math/asinhf.h"
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
 #include "utils/MPFRWrapper/MPFRUtils.h"
 
+#ifdef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+#define TOLERANCE 1
+#else
+#define TOLERANCE 0
+#endif // LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+
 using LlvmLibcAsinhfTest = LIBC_NAMESPACE::testing::FPTest<float>;
 
 namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
@@ -68,8 +75,8 @@ TEST_F(LlvmLibcAsinhfTest, SpecificBitPatterns) {
   for (int i = 0; i < N; ++i) {
     float x = FPBits(INPUTS[i]).get_val();
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Asinh, x,
-                                   LIBC_NAMESPACE::asinhf(x), 0.5);
+                                   LIBC_NAMESPACE::asinhf(x), TOLERANCE + 0.5);
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Asinh, -x,
-                                   LIBC_NAMESPACE::asinhf(-x), 0.5);
+                                   LIBC_NAMESPACE::asinhf(-x), TOLERANCE + 0.5);
   }
 }
diff --git a/libc/test/src/math/atan2f_test.cpp b/libc/test/src/math/atan2f_test.cpp
index 50ab38208089a..56b6967069523 100644
--- a/libc/test/src/math/atan2f_test.cpp
+++ b/libc/test/src/math/atan2f_test.cpp
@@ -8,11 +8,18 @@
 
 #include "hdr/math_macros.h"
 #include "src/__support/FPUtil/FPBits.h"
+#include "src/__support/macros/optimization.h"
 #include "src/math/atan2f.h"
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
 #include "utils/MPFRWrapper/MPFRUtils.h"
 
+#ifdef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+#define TOLERANCE 1
+#else
+#define TOLERANCE 0
+#endif // LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+
 using LlvmLibcAtan2fTest = LIBC_NAMESPACE::testing::FPTest<float>;
 using LIBC_NAMESPACE::testing::tlog;
 
@@ -36,16 +43,20 @@ TEST_F(LlvmLibcAtan2fTest, TrickyInputs) {
     float x = INPUTS[i].x;
     float y = INPUTS[i].y;
     ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Atan2, INPUTS[i],
-                                   LIBC_NAMESPACE::atan2f(x, y), 0.5);
+                                   LIBC_NAMESPACE::atan2f(x, y),
+                                   TOLERANCE + 0.5);
     INPUTS[i].x = -INPUTS[i].x;
     ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Atan2, INPUTS[i],
-                                   LIBC_NAMESPACE::atan2f(-x, y), 0.5);
+                                   LIBC_NAMESPACE::atan2f(-x, y),
+                                   TOLERANCE + 0.5);
     INPUTS[i].y = -INPUTS[i].y;
     ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Atan2, INPUTS[i],
-                                   LIBC_NAMESPACE::atan2f(-x, -y), 0.5);
+                                   LIBC_NAMESPACE::atan2f(-x, -y),
+                                   TOLERANCE + 0.5);
     INPUTS[i].x = -INPUTS[i].x;
     ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Atan2, INPUTS[i],
-                                   LIBC_NAMESPACE::atan2f(x, -y), 0.5);
+                                   LIBC_NAMESPACE::atan2f(x, -y),
+                                   TOLERANCE + 0.5);
   }
 }
 
diff --git a/libc/test/src/math/atanf16_test.cpp b/libc/test/src/math/atanf16_test.cpp
index fa383e718834e..e91133fc6e4ca 100644
--- a/libc/test/src/math/atanf16_test.cpp
+++ b/libc/test/src/math/atanf16_test.cpp
@@ -6,11 +6,18 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "src/__support/macros/optimization.h"
 #include "src/math/atanf16.h"
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
 #include "utils/MPFRWrapper/MPFRUtils.h"
 
+#ifdef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+#define TOLERANCE 1
+#else
+#define TOLERANCE 0
+#endif // LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+
 using LlvmLibcAtanf16Test = LIBC_NAMESPACE::testing::FPTest<float16>;
 
 namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
@@ -27,7 +34,7 @@ TEST_F(LlvmLibcAtanf16Test, PositiveRange) {
   for (uint16_t v = POS_START; v <= POS_STOP; ++v) {
     float16 x = FPBits(...
[truncated]

@jhuber6 jhuber6 merged commit 2bc4ad3 into llvm:main Oct 22, 2025
22 checks passed
@lntue lntue deleted the math_test branch October 22, 2025 03:49
googlewalt added a commit to googlewalt/llvm-project that referenced this pull request Oct 22, 2025
googlewalt added a commit that referenced this pull request Oct 22, 2025
googlewalt added a commit to googlewalt/llvm-project that referenced this pull request Oct 22, 2025
googlewalt added a commit that referenced this pull request Oct 22, 2025
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.

3 participants