[libc-commits] [libc] [libc][math] Add tolerance to math tests so that they still work when accurate path is skipped. (PR #164522)

via libc-commits libc-commits at lists.llvm.org
Tue Oct 21 16:47:32 PDT 2025


https://github.com/lntue created https://github.com/llvm/llvm-project/pull/164522

None

>From 350f859f9c0f6b22f7e0c9dc95ae31b9c78f6302 Mon Sep 17 00:00:00 2001
From: Tue Ly <lntue.h at gmail.com>
Date: Tue, 21 Oct 2025 23:44:40 +0000
Subject: [PATCH] [libc][math] Add tolerance to math tests so that they still
 work when accurate path is skipped.

---
 libc/src/__support/math/atan2f.h       |  4 +-
 libc/test/UnitTest/FPMatcher.h         | 53 ++++++++++++++------------
 libc/test/src/math/acos_test.cpp       |  9 ++++-
 libc/test/src/math/acosf16_test.cpp    | 11 +++++-
 libc/test/src/math/acosf_test.cpp      | 11 +++++-
 libc/test/src/math/acoshf_test.cpp     |  9 ++++-
 libc/test/src/math/asin_test.cpp       | 11 +++++-
 libc/test/src/math/asinf_test.cpp      | 11 +++++-
 libc/test/src/math/asinhf16_test.cpp   | 13 ++++++-
 libc/test/src/math/asinhf_test.cpp     | 11 +++++-
 libc/test/src/math/atan2f_test.cpp     | 19 +++++++--
 libc/test/src/math/atanf16_test.cpp    | 11 +++++-
 libc/test/src/math/cbrt_test.cpp       | 13 +++++--
 libc/test/src/math/cos_test.cpp        |  9 ++++-
 libc/test/src/math/cosf16_test.cpp     | 11 +++++-
 libc/test/src/math/cosf_test.cpp       | 24 ++++++++----
 libc/test/src/math/coshf16_test.cpp    | 11 +++++-
 libc/test/src/math/erff_test.cpp       | 18 ++++++---
 libc/test/src/math/exp10_test.cpp      | 18 ++++++---
 libc/test/src/math/exp10f16_test.cpp   | 13 ++++++-
 libc/test/src/math/exp10m1f16_test.cpp | 13 ++++++-
 libc/test/src/math/exp10m1f_test.cpp   | 11 +++++-
 libc/test/src/math/exp2_test.cpp       |  6 +--
 libc/test/src/math/exp2f16_test.cpp    | 11 +++++-
 libc/test/src/math/exp2f_test.cpp      | 10 ++++-
 libc/test/src/math/exp2m1f16_test.cpp  | 13 ++++++-
 libc/test/src/math/exp2m1f_test.cpp    | 10 ++++-
 libc/test/src/math/exp_test.cpp        | 18 ++++++---
 libc/test/src/math/expf16_test.cpp     | 11 +++++-
 libc/test/src/math/expf_test.cpp       | 10 ++++-
 libc/test/src/math/expm1_test.cpp      | 12 ++++--
 libc/test/src/math/expm1f16_test.cpp   | 13 ++++++-
 libc/test/src/math/expm1f_test.cpp     | 12 ++++--
 libc/test/src/math/log10_test.cpp      | 16 +++++---
 libc/test/src/math/log10f16_test.cpp   | 13 ++++++-
 libc/test/src/math/log10f_test.cpp     | 10 ++++-
 libc/test/src/math/log1p_test.cpp      | 19 +++++----
 libc/test/src/math/log1pf_test.cpp     | 10 ++++-
 libc/test/src/math/log2_test.cpp       |  6 +--
 libc/test/src/math/log2f16_test.cpp    | 10 ++++-
 libc/test/src/math/log_test.cpp        | 16 +++++---
 libc/test/src/math/logf16_test.cpp     | 11 +++++-
 libc/test/src/math/logf_test.cpp       | 14 ++++++-
 libc/test/src/math/powf_test.cpp       | 13 +++++--
 libc/test/src/math/sin_test.cpp        |  9 ++++-
 libc/test/src/math/sincos_test.cpp     | 23 +++++++----
 libc/test/src/math/sincosf_test.cpp    | 24 +++++++-----
 libc/test/src/math/sinf16_test.cpp     | 11 +++++-
 libc/test/src/math/sinf_test.cpp       | 36 ++++++++++-------
 libc/test/src/math/sinhf16_test.cpp    | 11 +++++-
 libc/test/src/math/sinhf_test.cpp      | 12 ++++--
 libc/test/src/math/smoke/sinf_test.cpp |  6 +++
 libc/test/src/math/tan_test.cpp        | 13 +++++--
 libc/test/src/math/tanf16_test.cpp     | 11 +++++-
 libc/test/src/math/tanf_test.cpp       | 11 +++++-
 libc/test/src/math/tanhf16_test.cpp    | 11 +++++-
 libc/test/src/math/tanpif16_test.cpp   | 13 ++++++-
 57 files changed, 579 insertions(+), 190 deletions(-)

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(v).get_val();
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Atan, x,
-                                   LIBC_NAMESPACE::atanf16(x), 0.5);
+                                   LIBC_NAMESPACE::atanf16(x), TOLERANCE + 0.5);
   }
 }
 
@@ -35,6 +42,6 @@ TEST_F(LlvmLibcAtanf16Test, NegativeRange) {
   for (uint16_t v = NEG_START; v <= NEG_STOP; ++v) {
     float16 x = FPBits(v).get_val();
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Atan, x,
-                                   LIBC_NAMESPACE::atanf16(x), 0.5);
+                                   LIBC_NAMESPACE::atanf16(x), TOLERANCE + 0.5);
   }
 }
diff --git a/libc/test/src/math/cbrt_test.cpp b/libc/test/src/math/cbrt_test.cpp
index 2e2de16fc859d..61b8583cbc7ff 100644
--- a/libc/test/src/math/cbrt_test.cpp
+++ b/libc/test/src/math/cbrt_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/cbrt.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 LlvmLibcCbrtTest = LIBC_NAMESPACE::testing::FPTest<double>;
 
 namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
@@ -49,7 +56,7 @@ TEST_F(LlvmLibcCbrtTest, InDoubleRange) {
       ++tested;
 
       if (!TEST_MPFR_MATCH_ROUNDING_SILENTLY(mpfr::Operation::Cbrt, x, result,
-                                             0.5, rounding_mode)) {
+                                             TOLERANCE + 0.5, rounding_mode)) {
         ++fails;
         while (!TEST_MPFR_MATCH_ROUNDING_SILENTLY(mpfr::Operation::Cbrt, x,
                                                   result, ulp, rounding_mode)) {
@@ -98,8 +105,8 @@ TEST_F(LlvmLibcCbrtTest, SpecialValues) {
   for (double v : INPUTS) {
     double x = FPBits(v).get_val();
     ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Cbrt, x,
-                                   LIBC_NAMESPACE::cbrt(x), 0.5);
+                                   LIBC_NAMESPACE::cbrt(x), TOLERANCE + 0.5);
     ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Cbrt, -x,
-                                   LIBC_NAMESPACE::cbrt(-x), 0.5);
+                                   LIBC_NAMESPACE::cbrt(-x), TOLERANCE + 0.5);
   }
 }
diff --git a/libc/test/src/math/cos_test.cpp b/libc/test/src/math/cos_test.cpp
index e2d47917e545e..40c43f9894639 100644
--- a/libc/test/src/math/cos_test.cpp
+++ b/libc/test/src/math/cos_test.cpp
@@ -7,11 +7,18 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/__support/FPUtil/FPBits.h"
+#include "src/__support/macros/optimization.h"
 #include "src/math/cos.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 LlvmLibcCosTest = LIBC_NAMESPACE::testing::FPTest<double>;
 
 namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
@@ -57,7 +64,7 @@ TEST_F(LlvmLibcCosTest, TrickyInputs) {
   for (int i = 0; i < N; ++i) {
     double x = INPUTS[i];
     ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Cos, x,
-                                   LIBC_NAMESPACE::cos(x), 0.5);
+                                   LIBC_NAMESPACE::cos(x), TOLERANCE + 0.5);
   }
 }
 
diff --git a/libc/test/src/math/cosf16_test.cpp b/libc/test/src/math/cosf16_test.cpp
index b744e7817e4ba..fe6f4abd39009 100644
--- a/libc/test/src/math/cosf16_test.cpp
+++ b/libc/test/src/math/cosf16_test.cpp
@@ -6,11 +6,18 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "src/__support/macros/optimization.h"
 #include "src/math/cosf16.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 LlvmLibcCosf16Test = LIBC_NAMESPACE::testing::FPTest<float16>;
 
 namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
@@ -27,7 +34,7 @@ TEST_F(LlvmLibcCosf16Test, PositiveRange) {
   for (uint16_t v = POS_START; v <= POS_STOP; ++v) {
     float16 x = FPBits(v).get_val();
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Cos, x,
-                                   LIBC_NAMESPACE::cosf16(x), 0.5);
+                                   LIBC_NAMESPACE::cosf16(x), TOLERANCE + 0.5);
   }
 }
 
@@ -35,6 +42,6 @@ TEST_F(LlvmLibcCosf16Test, NegativeRange) {
   for (uint16_t v = NEG_START; v <= NEG_STOP; ++v) {
     float16 x = FPBits(v).get_val();
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Cos, x,
-                                   LIBC_NAMESPACE::cosf16(x), 0.5);
+                                   LIBC_NAMESPACE::cosf16(x), TOLERANCE + 0.5);
   }
 }
diff --git a/libc/test/src/math/cosf_test.cpp b/libc/test/src/math/cosf_test.cpp
index 6afaa42e1f57d..d5d5dc3b4cd50 100644
--- a/libc/test/src/math/cosf_test.cpp
+++ b/libc/test/src/math/cosf_test.cpp
@@ -10,12 +10,21 @@
 #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/cosf.h"
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
 #include "test/src/math/sdcomp26094.h"
 #include "utils/MPFRWrapper/MPFRUtils.h"
 
+#ifdef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+#define TOLERANCE 3
+#define FP_ASSERT ASSERT_MPFR_MATCH
+#else
+#define TOLERANCE 0
+#define FP_ASSERT ASSERT_MPFR_MATCH_ALL_ROUNDING
+#endif // LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+
 using LIBC_NAMESPACE::testing::SDCOMP26094_VALUES;
 using LlvmLibcCosfTest = LIBC_NAMESPACE::testing::FPTest<float>;
 
@@ -45,8 +54,8 @@ TEST_F(LlvmLibcCosfTest, InFloatRange) {
     float x = FPBits(v).get_val();
     if (FPBits(v).is_nan() || FPBits(v).is_inf())
       continue;
-    ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Cos, x,
-                                   LIBC_NAMESPACE::cosf(x), 0.5);
+    FP_ASSERT(mpfr::Operation::Cos, x, LIBC_NAMESPACE::cosf(x),
+              TOLERANCE + 0.5);
   }
 }
 
@@ -99,10 +108,10 @@ TEST_F(LlvmLibcCosfTest, SpecificBitPatterns) {
 
   for (int i = 0; i < N; ++i) {
     float x = FPBits(INPUTS[i]).get_val();
-    EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Cos, x,
-                                   LIBC_NAMESPACE::cosf(x), 0.5);
-    EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Cos, -x,
-                                   LIBC_NAMESPACE::cosf(-x), 0.5);
+    FP_ASSERT(mpfr::Operation::Cos, x, LIBC_NAMESPACE::cosf(x),
+              TOLERANCE + 0.5);
+    FP_ASSERT(mpfr::Operation::Cos, -x, LIBC_NAMESPACE::cosf(-x),
+              TOLERANCE + 0.5);
   }
 }
 
@@ -111,6 +120,7 @@ TEST_F(LlvmLibcCosfTest, SpecificBitPatterns) {
 TEST_F(LlvmLibcCosfTest, SDCOMP_26094) {
   for (uint32_t v : SDCOMP26094_VALUES) {
     float x = FPBits(v).get_val();
-    ASSERT_MPFR_MATCH(mpfr::Operation::Cos, x, LIBC_NAMESPACE::cosf(x), 0.5);
+    FP_ASSERT(mpfr::Operation::Cos, x, LIBC_NAMESPACE::cosf(x),
+              TOLERANCE + 0.5);
   }
 }
diff --git a/libc/test/src/math/coshf16_test.cpp b/libc/test/src/math/coshf16_test.cpp
index a0d1fd2110478..8e8f55e128edf 100644
--- a/libc/test/src/math/coshf16_test.cpp
+++ b/libc/test/src/math/coshf16_test.cpp
@@ -6,11 +6,18 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "src/__support/macros/optimization.h"
 #include "src/math/coshf16.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 LlvmLibcCoshf16Test = LIBC_NAMESPACE::testing::FPTest<float16>;
 
 namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
@@ -27,7 +34,7 @@ TEST_F(LlvmLibcCoshf16Test, PositiveRange) {
   for (uint16_t v = POS_START; v <= POS_STOP; ++v) {
     float16 x = FPBits(v).get_val();
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Cosh, x,
-                                   LIBC_NAMESPACE::coshf16(x), 0.5);
+                                   LIBC_NAMESPACE::coshf16(x), TOLERANCE + 0.5);
   }
 }
 
@@ -35,6 +42,6 @@ TEST_F(LlvmLibcCoshf16Test, NegativeRange) {
   for (uint16_t v = NEG_START; v <= NEG_STOP; ++v) {
     float16 x = FPBits(v).get_val();
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Cosh, x,
-                                   LIBC_NAMESPACE::coshf16(x), 0.5);
+                                   LIBC_NAMESPACE::coshf16(x), TOLERANCE + 0.5);
   }
 }
diff --git a/libc/test/src/math/erff_test.cpp b/libc/test/src/math/erff_test.cpp
index c40aacf852bc9..17ff6c43f7717 100644
--- a/libc/test/src/math/erff_test.cpp
+++ b/libc/test/src/math/erff_test.cpp
@@ -7,13 +7,19 @@
 //===----------------------------------------------------------------------===//
 
 #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/erff.h"
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
 #include "utils/MPFRWrapper/MPFRUtils.h"
 
-#include "hdr/stdint_proxy.h"
+#ifdef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+#define TOLERANCE 1
+#else
+#define TOLERANCE 0
+#endif // LIBC_MATH_HAS_SKIP_ACCURATE_PASS
 
 using LlvmLibcErffTest = LIBC_NAMESPACE::testing::FPTest<float>;
 
@@ -37,9 +43,9 @@ TEST_F(LlvmLibcErffTest, TrickyInputs) {
   for (int i = 0; i < N; ++i) {
     float x = FPBits(INPUTS[i]).get_val();
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Erf, x,
-                                   LIBC_NAMESPACE::erff(x), 0.5);
+                                   LIBC_NAMESPACE::erff(x), TOLERANCE + 0.5);
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Erf, -x,
-                                   LIBC_NAMESPACE::erff(-x), 0.5);
+                                   LIBC_NAMESPACE::erff(-x), TOLERANCE + 0.5);
   }
 }
 
@@ -83,10 +89,10 @@ TEST_F(LlvmLibcErffTest, InFloatRange) {
         }
       }
     }
-    tlog << " Log failed: " << fails << "/" << count << "/" << cc
-         << " tests.\n";
-    tlog << "   Max ULPs is at most: " << static_cast<uint64_t>(tol) << ".\n";
     if (fails) {
+      tlog << " Log failed: " << fails << "/" << count << "/" << cc
+           << " tests.\n";
+      tlog << "   Max ULPs is at most: " << static_cast<uint64_t>(tol) << ".\n";
       EXPECT_MPFR_MATCH(mpfr::Operation::Erf, mx, mr, 0.5, rounding_mode);
     }
   };
diff --git a/libc/test/src/math/exp10_test.cpp b/libc/test/src/math/exp10_test.cpp
index 2ddcef0d77672..4257dd0d1458b 100644
--- a/libc/test/src/math/exp10_test.cpp
+++ b/libc/test/src/math/exp10_test.cpp
@@ -7,13 +7,19 @@
 //===----------------------------------------------------------------------===//
 
 #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/exp10.h"
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
 #include "utils/MPFRWrapper/MPFRUtils.h"
 
-#include "hdr/stdint_proxy.h"
+#ifdef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+#define TOLERANCE 1
+#else
+#define TOLERANCE 0
+#endif // LIBC_MATH_HAS_SKIP_ACCURATE_PASS
 
 using LlvmLibcExp10Test = LIBC_NAMESPACE::testing::FPTest<double>;
 
@@ -79,7 +85,7 @@ TEST_F(LlvmLibcExp10Test, TrickyInputs) {
   for (int i = 0; i < N; ++i) {
     double x = FPBits(INPUTS[i]).get_val();
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp10, x,
-                                   LIBC_NAMESPACE::exp10(x), 0.5);
+                                   LIBC_NAMESPACE::exp10(x), TOLERANCE + 0.5);
   }
 }
 
@@ -112,7 +118,7 @@ TEST_F(LlvmLibcExp10Test, InDoubleRange) {
       ++count;
 
       if (!TEST_MPFR_MATCH_ROUNDING_SILENTLY(mpfr::Operation::Exp10, x, result,
-                                             0.5, rounding_mode)) {
+                                             TOLERANCE + 0.5, rounding_mode)) {
         ++fails;
         while (!TEST_MPFR_MATCH_ROUNDING_SILENTLY(mpfr::Operation::Exp10, x,
                                                   result, tol, rounding_mode)) {
@@ -126,10 +132,10 @@ TEST_F(LlvmLibcExp10Test, InDoubleRange) {
         }
       }
     }
-    tlog << " Exp10 failed: " << fails << "/" << count << "/" << cc
-         << " tests.\n";
-    tlog << "   Max ULPs is at most: " << static_cast<uint64_t>(tol) << ".\n";
     if (fails) {
+      tlog << " Exp10 failed: " << fails << "/" << count << "/" << cc
+           << " tests.\n";
+      tlog << "   Max ULPs is at most: " << static_cast<uint64_t>(tol) << ".\n";
       EXPECT_MPFR_MATCH(mpfr::Operation::Exp10, mx, mr, 0.5, rounding_mode);
     }
   };
diff --git a/libc/test/src/math/exp10f16_test.cpp b/libc/test/src/math/exp10f16_test.cpp
index fc49331b5917c..7bd085012e583 100644
--- a/libc/test/src/math/exp10f16_test.cpp
+++ b/libc/test/src/math/exp10f16_test.cpp
@@ -6,11 +6,18 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "src/__support/macros/optimization.h"
 #include "src/math/exp10f16.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 LlvmLibcExp10f16Test = LIBC_NAMESPACE::testing::FPTest<float16>;
 
 namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
@@ -27,7 +34,8 @@ TEST_F(LlvmLibcExp10f16Test, PositiveRange) {
   for (uint16_t v = POS_START; v <= POS_STOP; ++v) {
     float16 x = FPBits(v).get_val();
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp10, x,
-                                   LIBC_NAMESPACE::exp10f16(x), 0.5);
+                                   LIBC_NAMESPACE::exp10f16(x),
+                                   TOLERANCE + 0.5);
   }
 }
 
@@ -35,6 +43,7 @@ TEST_F(LlvmLibcExp10f16Test, NegativeRange) {
   for (uint16_t v = NEG_START; v <= NEG_STOP; ++v) {
     float16 x = FPBits(v).get_val();
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp10, x,
-                                   LIBC_NAMESPACE::exp10f16(x), 0.5);
+                                   LIBC_NAMESPACE::exp10f16(x),
+                                   TOLERANCE + 0.5);
   }
 }
diff --git a/libc/test/src/math/exp10m1f16_test.cpp b/libc/test/src/math/exp10m1f16_test.cpp
index 41bb12f7d0973..4ba16e0e70b69 100644
--- a/libc/test/src/math/exp10m1f16_test.cpp
+++ b/libc/test/src/math/exp10m1f16_test.cpp
@@ -6,11 +6,18 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "src/__support/macros/optimization.h"
 #include "src/math/exp10m1f16.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 LlvmLibcExp10m1f16Test = LIBC_NAMESPACE::testing::FPTest<float16>;
 
 namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
@@ -27,7 +34,8 @@ TEST_F(LlvmLibcExp10m1f16Test, PositiveRange) {
   for (uint16_t v = POS_START; v <= POS_STOP; ++v) {
     float16 x = FPBits(v).get_val();
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp10m1, x,
-                                   LIBC_NAMESPACE::exp10m1f16(x), 0.5);
+                                   LIBC_NAMESPACE::exp10m1f16(x),
+                                   TOLERANCE + 0.5);
   }
 }
 
@@ -35,6 +43,7 @@ TEST_F(LlvmLibcExp10m1f16Test, NegativeRange) {
   for (uint16_t v = NEG_START; v <= NEG_STOP; ++v) {
     float16 x = FPBits(v).get_val();
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp10m1, x,
-                                   LIBC_NAMESPACE::exp10m1f16(x), 0.5);
+                                   LIBC_NAMESPACE::exp10m1f16(x),
+                                   TOLERANCE + 0.5);
   }
 }
diff --git a/libc/test/src/math/exp10m1f_test.cpp b/libc/test/src/math/exp10m1f_test.cpp
index 009c85d6cc453..b41a412b3bddc 100644
--- a/libc/test/src/math/exp10m1f_test.cpp
+++ b/libc/test/src/math/exp10m1f_test.cpp
@@ -7,14 +7,20 @@
 //===----------------------------------------------------------------------===//
 
 #include "hdr/math_macros.h"
+#include "hdr/stdint_proxy.h"
 #include "src/__support/CPP/array.h"
 #include "src/__support/libc_errno.h"
+#include "src/__support/macros/optimization.h"
 #include "src/math/exp10m1f.h"
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
 #include "utils/MPFRWrapper/MPFRUtils.h"
 
-#include "hdr/stdint_proxy.h"
+#ifdef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+#define TOLERANCE 1
+#else
+#define TOLERANCE 0
+#endif // LIBC_MATH_HAS_SKIP_ACCURATE_PASS
 
 using LlvmLibcExp10m1fTest = LIBC_NAMESPACE::testing::FPTest<float>;
 
@@ -70,7 +76,8 @@ TEST_F(LlvmLibcExp10m1fTest, TrickyInputs) {
 
   for (float x : INPUTS) {
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp10m1, x,
-                                   LIBC_NAMESPACE::exp10m1f(x), 0.5);
+                                   LIBC_NAMESPACE::exp10m1f(x),
+                                   TOLERANCE + 0.5);
   }
 }
 
diff --git a/libc/test/src/math/exp2_test.cpp b/libc/test/src/math/exp2_test.cpp
index a3dcb58c5c288..324cafd926756 100644
--- a/libc/test/src/math/exp2_test.cpp
+++ b/libc/test/src/math/exp2_test.cpp
@@ -101,10 +101,10 @@ TEST_F(LlvmLibcExp2Test, InDoubleRange) {
         }
       }
     }
-    tlog << " Exp2 failed: " << fails << "/" << count << "/" << cc
-         << " tests.\n";
-    tlog << "   Max ULPs is at most: " << static_cast<uint64_t>(tol) << ".\n";
     if (fails) {
+      tlog << " Exp2 failed: " << fails << "/" << count << "/" << cc
+           << " tests.\n";
+      tlog << "   Max ULPs is at most: " << static_cast<uint64_t>(tol) << ".\n";
       EXPECT_MPFR_MATCH(mpfr::Operation::Exp2, mx, mr, 0.5, rounding_mode);
     }
   };
diff --git a/libc/test/src/math/exp2f16_test.cpp b/libc/test/src/math/exp2f16_test.cpp
index 503d8c2d89d94..d28632a77c4cb 100644
--- a/libc/test/src/math/exp2f16_test.cpp
+++ b/libc/test/src/math/exp2f16_test.cpp
@@ -6,11 +6,18 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "src/__support/macros/optimization.h"
 #include "src/math/exp2f16.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 LlvmLibcExp2f16Test = LIBC_NAMESPACE::testing::FPTest<float16>;
 
 namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
@@ -27,7 +34,7 @@ TEST_F(LlvmLibcExp2f16Test, PositiveRange) {
   for (uint16_t v = POS_START; v <= POS_STOP; ++v) {
     float16 x = FPBits(v).get_val();
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp2, x,
-                                   LIBC_NAMESPACE::exp2f16(x), 0.5);
+                                   LIBC_NAMESPACE::exp2f16(x), TOLERANCE + 0.5);
   }
 }
 
@@ -35,6 +42,6 @@ TEST_F(LlvmLibcExp2f16Test, NegativeRange) {
   for (uint16_t v = NEG_START; v <= NEG_STOP; ++v) {
     float16 x = FPBits(v).get_val();
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp2, x,
-                                   LIBC_NAMESPACE::exp2f16(x), 0.5);
+                                   LIBC_NAMESPACE::exp2f16(x), TOLERANCE + 0.5);
   }
 }
diff --git a/libc/test/src/math/exp2f_test.cpp b/libc/test/src/math/exp2f_test.cpp
index 94141dda71843..5e5fd699ab4ac 100644
--- a/libc/test/src/math/exp2f_test.cpp
+++ b/libc/test/src/math/exp2f_test.cpp
@@ -7,14 +7,20 @@
 //===----------------------------------------------------------------------===//
 
 #include "hdr/math_macros.h"
+#include "hdr/stdint_proxy.h"
 #include "src/__support/FPUtil/FPBits.h"
 #include "src/__support/libc_errno.h"
+#include "src/__support/macros/optimization.h"
 #include "src/math/exp2f.h"
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
 #include "utils/MPFRWrapper/MPFRUtils.h"
 
-#include "hdr/stdint_proxy.h"
+#ifdef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+#define TOLERANCE 1
+#else
+#define TOLERANCE 0
+#endif // LIBC_MATH_HAS_SKIP_ACCURATE_PASS
 
 using LlvmLibcExp2fTest = LIBC_NAMESPACE::testing::FPTest<float>;
 
@@ -71,7 +77,7 @@ TEST_F(LlvmLibcExp2fTest, TrickyInputs) {
     libc_errno = 0;
     float x = FPBits(INPUTS[i]).get_val();
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp2, x,
-                                   LIBC_NAMESPACE::exp2f(x), 0.5);
+                                   LIBC_NAMESPACE::exp2f(x), TOLERANCE + 0.5);
     EXPECT_MATH_ERRNO(0);
   }
 }
diff --git a/libc/test/src/math/exp2m1f16_test.cpp b/libc/test/src/math/exp2m1f16_test.cpp
index bf299118429d7..526484d8d196b 100644
--- a/libc/test/src/math/exp2m1f16_test.cpp
+++ b/libc/test/src/math/exp2m1f16_test.cpp
@@ -6,11 +6,18 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "src/__support/macros/optimization.h"
 #include "src/math/exp2m1f16.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 LlvmLibcExp2m1f16Test = LIBC_NAMESPACE::testing::FPTest<float16>;
 
 namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
@@ -27,7 +34,8 @@ TEST_F(LlvmLibcExp2m1f16Test, PositiveRange) {
   for (uint16_t v = POS_START; v <= POS_STOP; ++v) {
     float16 x = FPBits(v).get_val();
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp2m1, x,
-                                   LIBC_NAMESPACE::exp2m1f16(x), 0.5);
+                                   LIBC_NAMESPACE::exp2m1f16(x),
+                                   TOLERANCE + 0.5);
   }
 }
 
@@ -35,6 +43,7 @@ TEST_F(LlvmLibcExp2m1f16Test, NegativeRange) {
   for (uint16_t v = NEG_START; v <= NEG_STOP; ++v) {
     float16 x = FPBits(v).get_val();
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp2m1, x,
-                                   LIBC_NAMESPACE::exp2m1f16(x), 0.5);
+                                   LIBC_NAMESPACE::exp2m1f16(x),
+                                   TOLERANCE + 0.5);
   }
 }
diff --git a/libc/test/src/math/exp2m1f_test.cpp b/libc/test/src/math/exp2m1f_test.cpp
index 7e9f6b50ce816..16b20d72e2958 100644
--- a/libc/test/src/math/exp2m1f_test.cpp
+++ b/libc/test/src/math/exp2m1f_test.cpp
@@ -7,15 +7,21 @@
 //===----------------------------------------------------------------------===//
 
 #include "hdr/math_macros.h"
+#include "hdr/stdint_proxy.h"
 #include "src/__support/CPP/array.h"
 #include "src/__support/FPUtil/FPBits.h"
 #include "src/__support/libc_errno.h"
+#include "src/__support/macros/optimization.h"
 #include "src/math/exp2m1f.h"
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
 #include "utils/MPFRWrapper/MPFRUtils.h"
 
-#include "hdr/stdint_proxy.h"
+#ifdef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+#define TOLERANCE 1
+#else
+#define TOLERANCE 0
+#endif // LIBC_MATH_HAS_SKIP_ACCURATE_PASS
 
 using LlvmLibcExp2m1fTest = LIBC_NAMESPACE::testing::FPTest<float>;
 
@@ -39,7 +45,7 @@ TEST_F(LlvmLibcExp2m1fTest, TrickyInputs) {
 
   for (float x : INPUTS) {
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp2m1, x,
-                                   LIBC_NAMESPACE::exp2m1f(x), 0.5);
+                                   LIBC_NAMESPACE::exp2m1f(x), TOLERANCE + 0.5);
   }
 }
 
diff --git a/libc/test/src/math/exp_test.cpp b/libc/test/src/math/exp_test.cpp
index 854bb5155e11d..5a785fbaee4fd 100644
--- a/libc/test/src/math/exp_test.cpp
+++ b/libc/test/src/math/exp_test.cpp
@@ -7,13 +7,19 @@
 //===----------------------------------------------------------------------===//
 
 #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/exp.h"
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
 #include "utils/MPFRWrapper/MPFRUtils.h"
 
-#include "hdr/stdint_proxy.h"
+#ifdef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+#define TOLERANCE 1
+#else
+#define TOLERANCE 0
+#endif // LIBC_MATH_HAS_SKIP_ACCURATE_PASS
 
 using LlvmLibcExpTest = LIBC_NAMESPACE::testing::FPTest<double>;
 
@@ -52,7 +58,7 @@ TEST_F(LlvmLibcExpTest, TrickyInputs) {
   for (int i = 0; i < N; ++i) {
     double x = FPBits(INPUTS[i]).get_val();
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp, x,
-                                   LIBC_NAMESPACE::exp(x), 0.5);
+                                   LIBC_NAMESPACE::exp(x), TOLERANCE + 0.5);
   }
 }
 
@@ -85,7 +91,7 @@ TEST_F(LlvmLibcExpTest, InDoubleRange) {
       ++count;
       // ASSERT_MPFR_MATCH(mpfr::Operation::Log, x, result, 0.5);
       if (!TEST_MPFR_MATCH_ROUNDING_SILENTLY(mpfr::Operation::Exp, x, result,
-                                             0.5, rounding_mode)) {
+                                             TOLERANCE + 0.5, rounding_mode)) {
         ++fails;
         while (!TEST_MPFR_MATCH_ROUNDING_SILENTLY(mpfr::Operation::Exp, x,
                                                   result, tol, rounding_mode)) {
@@ -99,10 +105,10 @@ TEST_F(LlvmLibcExpTest, InDoubleRange) {
         }
       }
     }
-    tlog << " Exp failed: " << fails << "/" << count << "/" << cc
-         << " tests.\n";
-    tlog << "   Max ULPs is at most: " << static_cast<uint64_t>(tol) << ".\n";
     if (fails) {
+      tlog << " Exp failed: " << fails << "/" << count << "/" << cc
+           << " tests.\n";
+      tlog << "   Max ULPs is at most: " << static_cast<uint64_t>(tol) << ".\n";
       EXPECT_MPFR_MATCH(mpfr::Operation::Exp, mx, mr, 0.5, rounding_mode);
     }
   };
diff --git a/libc/test/src/math/expf16_test.cpp b/libc/test/src/math/expf16_test.cpp
index ee89a9c716e12..4ea10ea5c8ad4 100644
--- a/libc/test/src/math/expf16_test.cpp
+++ b/libc/test/src/math/expf16_test.cpp
@@ -6,11 +6,18 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "src/__support/macros/optimization.h"
 #include "src/math/expf16.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 LlvmLibcExpf16Test = LIBC_NAMESPACE::testing::FPTest<float16>;
 
 namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
@@ -27,7 +34,7 @@ TEST_F(LlvmLibcExpf16Test, PositiveRange) {
   for (uint16_t v = POS_START; v <= POS_STOP; ++v) {
     float16 x = FPBits(v).get_val();
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp, x,
-                                   LIBC_NAMESPACE::expf16(x), 0.5);
+                                   LIBC_NAMESPACE::expf16(x), TOLERANCE + 0.5);
   }
 }
 
@@ -35,6 +42,6 @@ TEST_F(LlvmLibcExpf16Test, NegativeRange) {
   for (uint16_t v = NEG_START; v <= NEG_STOP; ++v) {
     float16 x = FPBits(v).get_val();
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp, x,
-                                   LIBC_NAMESPACE::expf16(x), 0.5);
+                                   LIBC_NAMESPACE::expf16(x), TOLERANCE + 0.5);
   }
 }
diff --git a/libc/test/src/math/expf_test.cpp b/libc/test/src/math/expf_test.cpp
index 1695a60fbd491..05167b80ec06a 100644
--- a/libc/test/src/math/expf_test.cpp
+++ b/libc/test/src/math/expf_test.cpp
@@ -7,14 +7,20 @@
 //===----------------------------------------------------------------------===//
 
 #include "hdr/math_macros.h"
+#include "hdr/stdint_proxy.h"
 #include "src/__support/FPUtil/FPBits.h"
 #include "src/__support/libc_errno.h"
+#include "src/__support/macros/optimization.h"
 #include "src/math/expf.h"
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
 #include "utils/MPFRWrapper/MPFRUtils.h"
 
-#include "hdr/stdint_proxy.h"
+#ifdef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+#define TOLERANCE 1
+#else
+#define TOLERANCE 0
+#endif // LIBC_MATH_HAS_SKIP_ACCURATE_PASS
 
 using LlvmLibcExpfTest = LIBC_NAMESPACE::testing::FPTest<float>;
 
@@ -94,7 +100,7 @@ TEST_F(LlvmLibcExpfTest, Borderline) {
 
   x = FPBits(0xc236bd8cU).get_val();
   EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp, x,
-                                 LIBC_NAMESPACE::expf(x), 0.5);
+                                 LIBC_NAMESPACE::expf(x), TOLERANCE + 0.5);
   EXPECT_MATH_ERRNO(0);
 }
 
diff --git a/libc/test/src/math/expm1_test.cpp b/libc/test/src/math/expm1_test.cpp
index c185be9e35f60..8ca9b7710427b 100644
--- a/libc/test/src/math/expm1_test.cpp
+++ b/libc/test/src/math/expm1_test.cpp
@@ -7,13 +7,19 @@
 //===----------------------------------------------------------------------===//
 
 #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/expm1.h"
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
 #include "utils/MPFRWrapper/MPFRUtils.h"
 
-#include "hdr/stdint_proxy.h"
+#ifdef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+#define TOLERANCE 1
+#else
+#define TOLERANCE 0
+#endif // LIBC_MATH_HAS_SKIP_ACCURATE_PASS
 
 using LlvmLibcExpm1Test = LIBC_NAMESPACE::testing::FPTest<double>;
 
@@ -36,9 +42,9 @@ TEST_F(LlvmLibcExpm1Test, TrickyInputs) {
   for (int i = 0; i < N; ++i) {
     double x = INPUTS[i];
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Expm1, x,
-                                   LIBC_NAMESPACE::expm1(x), 0.5);
+                                   LIBC_NAMESPACE::expm1(x), TOLERANCE + 0.5);
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Expm1, -x,
-                                   LIBC_NAMESPACE::expm1(-x), 0.5);
+                                   LIBC_NAMESPACE::expm1(-x), TOLERANCE + 0.5);
   }
 }
 
diff --git a/libc/test/src/math/expm1f16_test.cpp b/libc/test/src/math/expm1f16_test.cpp
index a6a6fcf73d383..952a8796ea7c3 100644
--- a/libc/test/src/math/expm1f16_test.cpp
+++ b/libc/test/src/math/expm1f16_test.cpp
@@ -6,11 +6,18 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "src/__support/macros/optimization.h"
 #include "src/math/expm1f16.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 LlvmLibcExpm1f16Test = LIBC_NAMESPACE::testing::FPTest<float16>;
 
 namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
@@ -27,7 +34,8 @@ TEST_F(LlvmLibcExpm1f16Test, PositiveRange) {
   for (uint16_t v = POS_START; v <= POS_STOP; ++v) {
     float16 x = FPBits(v).get_val();
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Expm1, x,
-                                   LIBC_NAMESPACE::expm1f16(x), 0.5);
+                                   LIBC_NAMESPACE::expm1f16(x),
+                                   TOLERANCE + 0.5);
   }
 }
 
@@ -35,6 +43,7 @@ TEST_F(LlvmLibcExpm1f16Test, NegativeRange) {
   for (uint16_t v = NEG_START; v <= NEG_STOP; ++v) {
     float16 x = FPBits(v).get_val();
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Expm1, x,
-                                   LIBC_NAMESPACE::expm1f16(x), 0.5);
+                                   LIBC_NAMESPACE::expm1f16(x),
+                                   TOLERANCE + 0.5);
   }
 }
diff --git a/libc/test/src/math/expm1f_test.cpp b/libc/test/src/math/expm1f_test.cpp
index 28d7106397801..2f7a9f2de78f3 100644
--- a/libc/test/src/math/expm1f_test.cpp
+++ b/libc/test/src/math/expm1f_test.cpp
@@ -7,14 +7,20 @@
 //===----------------------------------------------------------------------===//
 
 #include "hdr/math_macros.h"
+#include "hdr/stdint_proxy.h"
 #include "src/__support/FPUtil/FPBits.h"
 #include "src/__support/libc_errno.h"
+#include "src/__support/macros/optimization.h"
 #include "src/math/expm1f.h"
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
 #include "utils/MPFRWrapper/MPFRUtils.h"
 
-#include "hdr/stdint_proxy.h"
+#ifdef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+#define TOLERANCE 1
+#else
+#define TOLERANCE 0
+#endif // LIBC_MATH_HAS_SKIP_ACCURATE_PASS
 
 using LlvmLibcExpm1fTest = LIBC_NAMESPACE::testing::FPTest<float>;
 
@@ -93,7 +99,7 @@ TEST_F(LlvmLibcExpm1fTest, Borderline) {
 
   x = FPBits(0x3e35bec5U).get_val();
   ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Expm1, x,
-                                 LIBC_NAMESPACE::expm1f(x), 0.5);
+                                 LIBC_NAMESPACE::expm1f(x), TOLERANCE + 0.5);
   EXPECT_MATH_ERRNO(0);
 
   x = FPBits(0x942ed494U).get_val();
@@ -103,7 +109,7 @@ TEST_F(LlvmLibcExpm1fTest, Borderline) {
 
   x = FPBits(0xbdc1c6cbU).get_val();
   ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Expm1, x,
-                                 LIBC_NAMESPACE::expm1f(x), 0.5);
+                                 LIBC_NAMESPACE::expm1f(x), TOLERANCE + 0.5);
   EXPECT_MATH_ERRNO(0);
 }
 
diff --git a/libc/test/src/math/log10_test.cpp b/libc/test/src/math/log10_test.cpp
index 62a19d02309ad..3e48f7447b6cb 100644
--- a/libc/test/src/math/log10_test.cpp
+++ b/libc/test/src/math/log10_test.cpp
@@ -7,13 +7,19 @@
 //===----------------------------------------------------------------------===//
 
 #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/log10.h"
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
 #include "utils/MPFRWrapper/MPFRUtils.h"
 
-#include "hdr/stdint_proxy.h"
+#ifdef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+#define TOLERANCE 1
+#else
+#define TOLERANCE 0
+#endif // LIBC_MATH_HAS_SKIP_ACCURATE_PASS
 
 using LlvmLibcLog10Test = LIBC_NAMESPACE::testing::FPTest<double>;
 
@@ -66,7 +72,7 @@ TEST_F(LlvmLibcLog10Test, TrickyInputs) {
   for (int i = 0; i < N; ++i) {
     double x = FPBits(INPUTS[i]).get_val();
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Log10, x,
-                                   LIBC_NAMESPACE::log10(x), 0.5);
+                                   LIBC_NAMESPACE::log10(x), TOLERANCE + 0.5);
   }
 }
 
@@ -118,10 +124,10 @@ TEST_F(LlvmLibcLog10Test, InDoubleRange) {
         }
       }
     }
-    tlog << " Log10 failed: " << fails << "/" << count << "/" << cc
-         << " tests.\n";
-    tlog << "   Max ULPs is at most: " << static_cast<uint64_t>(tol) << ".\n";
     if (fails) {
+      tlog << " Log10 failed: " << fails << "/" << count << "/" << cc
+           << " tests.\n";
+      tlog << "   Max ULPs is at most: " << static_cast<uint64_t>(tol) << ".\n";
       EXPECT_MPFR_MATCH(mpfr::Operation::Log10, mx, mr, 0.5, rounding_mode);
     }
   };
diff --git a/libc/test/src/math/log10f16_test.cpp b/libc/test/src/math/log10f16_test.cpp
index a71e3309ac5f0..0e456dc96a6ce 100644
--- a/libc/test/src/math/log10f16_test.cpp
+++ b/libc/test/src/math/log10f16_test.cpp
@@ -6,11 +6,18 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "src/__support/macros/optimization.h"
 #include "src/math/log10f16.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 LlvmLibcLog10f16Test = LIBC_NAMESPACE::testing::FPTest<float16>;
 
 namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
@@ -27,7 +34,8 @@ TEST_F(LlvmLibcLog10f16Test, PositiveRange) {
   for (uint16_t v = POS_START; v <= POS_STOP; ++v) {
     float16 x = FPBits(v).get_val();
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Log10, x,
-                                   LIBC_NAMESPACE::log10f16(x), 0.5);
+                                   LIBC_NAMESPACE::log10f16(x),
+                                   TOLERANCE + 0.5);
   }
 }
 
@@ -35,6 +43,7 @@ TEST_F(LlvmLibcLog10f16Test, NegativeRange) {
   for (uint16_t v = NEG_START; v <= NEG_STOP; ++v) {
     float16 x = FPBits(v).get_val();
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Log10, x,
-                                   LIBC_NAMESPACE::log10f16(x), 0.5);
+                                   LIBC_NAMESPACE::log10f16(x),
+                                   TOLERANCE + 0.5);
   }
 }
diff --git a/libc/test/src/math/log10f_test.cpp b/libc/test/src/math/log10f_test.cpp
index c554948f7e647..1a1bd14a65d84 100644
--- a/libc/test/src/math/log10f_test.cpp
+++ b/libc/test/src/math/log10f_test.cpp
@@ -7,13 +7,19 @@
 //===----------------------------------------------------------------------===//
 
 #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/log10f.h"
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
 #include "utils/MPFRWrapper/MPFRUtils.h"
 
-#include "hdr/stdint_proxy.h"
+#ifdef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+#define TOLERANCE 1
+#else
+#define TOLERANCE 0
+#endif // LIBC_MATH_HAS_SKIP_ACCURATE_PASS
 
 using LlvmLibcLog10fTest = LIBC_NAMESPACE::testing::FPTest<float>;
 
@@ -60,7 +66,7 @@ TEST_F(LlvmLibcLog10fTest, TrickyInputs) {
   for (int i = 0; i < N; ++i) {
     float x = FPBits(INPUTS[i]).get_val();
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Log10, x,
-                                   LIBC_NAMESPACE::log10f(x), 0.5);
+                                   LIBC_NAMESPACE::log10f(x), TOLERANCE + 0.5);
   }
 }
 
diff --git a/libc/test/src/math/log1p_test.cpp b/libc/test/src/math/log1p_test.cpp
index be83ce899db59..dd720739ac569 100644
--- a/libc/test/src/math/log1p_test.cpp
+++ b/libc/test/src/math/log1p_test.cpp
@@ -7,13 +7,19 @@
 //===----------------------------------------------------------------------===//
 
 #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/log1p.h"
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
 #include "utils/MPFRWrapper/MPFRUtils.h"
 
-#include "hdr/stdint_proxy.h"
+#ifdef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+#define TOLERANCE 1
+#else
+#define TOLERANCE 0
+#endif // LIBC_MATH_HAS_SKIP_ACCURATE_PASS
 
 using LlvmLibcLog1pTest = LIBC_NAMESPACE::testing::FPTest<double>;
 
@@ -68,7 +74,7 @@ TEST_F(LlvmLibcLog1pTest, TrickyInputs) {
   for (int i = 0; i < N; ++i) {
     double x = FPBits(INPUTS[i]).get_val();
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Log1p, x,
-                                   LIBC_NAMESPACE::log1p(x), 0.5);
+                                   LIBC_NAMESPACE::log1p(x), TOLERANCE + 0.5);
   }
 }
 
@@ -107,9 +113,8 @@ TEST_F(LlvmLibcLog1pTest, InDoubleRange) {
         continue;
 
       ++count;
-      // ASSERT_MPFR_MATCH(mpfr::Operation::Log1p, x, result, 0.5);
       if (!TEST_MPFR_MATCH_ROUNDING_SILENTLY(mpfr::Operation::Log1p, x, result,
-                                             0.5, rounding_mode)) {
+                                             TOLERANCE + 0.5, rounding_mode)) {
         ++fails;
         while (!TEST_MPFR_MATCH_ROUNDING_SILENTLY(mpfr::Operation::Log1p, x,
                                                   result, tol, rounding_mode)) {
@@ -119,10 +124,10 @@ TEST_F(LlvmLibcLog1pTest, InDoubleRange) {
         }
       }
     }
-    tlog << " Log1p failed: " << fails << "/" << count << "/" << cc
-         << " tests.\n";
-    tlog << "   Max ULPs is at most: " << static_cast<uint64_t>(tol) << ".\n";
     if (fails) {
+      tlog << " Log1p failed: " << fails << "/" << count << "/" << cc
+           << " tests.\n";
+      tlog << "   Max ULPs is at most: " << static_cast<uint64_t>(tol) << ".\n";
       EXPECT_MPFR_MATCH(mpfr::Operation::Log1p, mx, mr, 0.5, rounding_mode);
     }
   };
diff --git a/libc/test/src/math/log1pf_test.cpp b/libc/test/src/math/log1pf_test.cpp
index 2df452629b98d..ef61f5ae41b1a 100644
--- a/libc/test/src/math/log1pf_test.cpp
+++ b/libc/test/src/math/log1pf_test.cpp
@@ -7,13 +7,19 @@
 //===----------------------------------------------------------------------===//
 
 #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/log1pf.h"
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
 #include "utils/MPFRWrapper/MPFRUtils.h"
 
-#include "hdr/stdint_proxy.h"
+#ifdef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+#define TOLERANCE 1
+#else
+#define TOLERANCE 0
+#endif // LIBC_MATH_HAS_SKIP_ACCURATE_PASS
 
 using LlvmLibcLog1pfTest = LIBC_NAMESPACE::testing::FPTest<float>;
 
@@ -63,7 +69,7 @@ TEST_F(LlvmLibcLog1pfTest, TrickyInputs) {
   for (int i = 0; i < N; ++i) {
     float x = FPBits(INPUTS[i]).get_val();
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Log1p, x,
-                                   LIBC_NAMESPACE::log1pf(x), 0.5);
+                                   LIBC_NAMESPACE::log1pf(x), TOLERANCE + 0.5);
   }
 }
 
diff --git a/libc/test/src/math/log2_test.cpp b/libc/test/src/math/log2_test.cpp
index 824a8a5d8bb70..9eada859ced84 100644
--- a/libc/test/src/math/log2_test.cpp
+++ b/libc/test/src/math/log2_test.cpp
@@ -117,10 +117,10 @@ TEST_F(LlvmLibcLog2Test, InDoubleRange) {
         }
       }
     }
-    tlog << " Log2 failed: " << fails << "/" << count << "/" << cc
-         << " tests.\n";
-    tlog << "   Max ULPs is at most: " << static_cast<uint64_t>(tol) << ".\n";
     if (fails) {
+      tlog << " Log2 failed: " << fails << "/" << count << "/" << cc
+           << " tests.\n";
+      tlog << "   Max ULPs is at most: " << static_cast<uint64_t>(tol) << ".\n";
       EXPECT_MPFR_MATCH(mpfr::Operation::Log2, mx, mr, 0.5, rounding_mode);
     }
   };
diff --git a/libc/test/src/math/log2f16_test.cpp b/libc/test/src/math/log2f16_test.cpp
index 6630ca877d8d1..d277b1233693d 100644
--- a/libc/test/src/math/log2f16_test.cpp
+++ b/libc/test/src/math/log2f16_test.cpp
@@ -6,11 +6,17 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "src/__support/macros/optimization.h"
 #include "src/math/log2f16.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 LlvmLibcLog2f16Test = LIBC_NAMESPACE::testing::FPTest<float16>;
 
 namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
@@ -27,7 +33,7 @@ TEST_F(LlvmLibcLog2f16Test, PositiveRange) {
   for (uint16_t v = POS_START; v <= POS_STOP; ++v) {
     float16 x = FPBits(v).get_val();
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Log2, x,
-                                   LIBC_NAMESPACE::log2f16(x), 0.5);
+                                   LIBC_NAMESPACE::log2f16(x), TOLERANCE + 0.5);
   }
 }
 
@@ -35,6 +41,6 @@ TEST_F(LlvmLibcLog2f16Test, NegativeRange) {
   for (uint16_t v = NEG_START; v <= NEG_STOP; ++v) {
     float16 x = FPBits(v).get_val();
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Log2, x,
-                                   LIBC_NAMESPACE::log2f16(x), 0.5);
+                                   LIBC_NAMESPACE::log2f16(x), TOLERANCE + 0.5);
   }
 }
diff --git a/libc/test/src/math/log_test.cpp b/libc/test/src/math/log_test.cpp
index a68d168721e57..c9a030a89c2fd 100644
--- a/libc/test/src/math/log_test.cpp
+++ b/libc/test/src/math/log_test.cpp
@@ -7,13 +7,19 @@
 //===----------------------------------------------------------------------===//
 
 #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/log.h"
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
 #include "utils/MPFRWrapper/MPFRUtils.h"
 
-#include "hdr/stdint_proxy.h"
+#ifdef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+#define TOLERANCE 1
+#else
+#define TOLERANCE 0
+#endif // LIBC_MATH_HAS_SKIP_ACCURATE_PASS
 
 using LlvmLibcLogTest = LIBC_NAMESPACE::testing::FPTest<double>;
 
@@ -106,7 +112,7 @@ TEST_F(LlvmLibcLogTest, InDoubleRange) {
       ++count;
       // ASSERT_MPFR_MATCH(mpfr::Operation::Log, x, result, 0.5);
       if (!TEST_MPFR_MATCH_ROUNDING_SILENTLY(mpfr::Operation::Log, x, result,
-                                             0.5, rounding_mode)) {
+                                             TOLERANCE + 0.5, rounding_mode)) {
         ++fails;
         while (!TEST_MPFR_MATCH_ROUNDING_SILENTLY(mpfr::Operation::Log, x,
                                                   result, tol, rounding_mode)) {
@@ -116,10 +122,10 @@ TEST_F(LlvmLibcLogTest, InDoubleRange) {
         }
       }
     }
-    tlog << " Log failed: " << fails << "/" << count << "/" << cc
-         << " tests.\n";
-    tlog << "   Max ULPs is at most: " << static_cast<uint64_t>(tol) << ".\n";
     if (fails) {
+      tlog << " Log failed: " << fails << "/" << count << "/" << cc
+           << " tests.\n";
+      tlog << "   Max ULPs is at most: " << static_cast<uint64_t>(tol) << ".\n";
       EXPECT_MPFR_MATCH(mpfr::Operation::Log, mx, mr, 0.5, rounding_mode);
     }
   };
diff --git a/libc/test/src/math/logf16_test.cpp b/libc/test/src/math/logf16_test.cpp
index 922918b092b21..70d6304208567 100644
--- a/libc/test/src/math/logf16_test.cpp
+++ b/libc/test/src/math/logf16_test.cpp
@@ -6,11 +6,18 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "src/__support/macros/optimization.h"
 #include "src/math/logf16.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 LlvmLibcLogf16Test = LIBC_NAMESPACE::testing::FPTest<float16>;
 
 namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
@@ -27,7 +34,7 @@ TEST_F(LlvmLibcLogf16Test, PositiveRange) {
   for (uint16_t v = POS_START; v <= POS_STOP; ++v) {
     float16 x = FPBits(v).get_val();
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Log, x,
-                                   LIBC_NAMESPACE::logf16(x), 0.5);
+                                   LIBC_NAMESPACE::logf16(x), TOLERANCE + 0.5);
   }
 }
 
@@ -35,6 +42,6 @@ TEST_F(LlvmLibcLogf16Test, NegativeRange) {
   for (uint16_t v = NEG_START; v <= NEG_STOP; ++v) {
     float16 x = FPBits(v).get_val();
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Log, x,
-                                   LIBC_NAMESPACE::logf16(x), 0.5);
+                                   LIBC_NAMESPACE::logf16(x), TOLERANCE + 0.5);
   }
 }
diff --git a/libc/test/src/math/logf_test.cpp b/libc/test/src/math/logf_test.cpp
index 7658075c1738f..fb99080435915 100644
--- a/libc/test/src/math/logf_test.cpp
+++ b/libc/test/src/math/logf_test.cpp
@@ -7,13 +7,19 @@
 //===----------------------------------------------------------------------===//
 
 #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/logf.h"
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
 #include "utils/MPFRWrapper/MPFRUtils.h"
 
-#include "hdr/stdint_proxy.h"
+#ifdef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+#define TOLERANCE 1
+#else
+#define TOLERANCE 0
+#endif // LIBC_MATH_HAS_SKIP_ACCURATE_PASS
 
 using LlvmLibcLogfTest = LIBC_NAMESPACE::testing::FPTest<float>;
 
@@ -28,7 +34,11 @@ TEST_F(LlvmLibcLogfTest, SpecialNumbers) {
   EXPECT_FP_EQ_WITH_EXCEPTION(neg_inf, LIBC_NAMESPACE::logf(-0.0f),
                               FE_DIVBYZERO);
   EXPECT_FP_IS_NAN_WITH_EXCEPTION(LIBC_NAMESPACE::logf(-1.0f), FE_INVALID);
+#ifdef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+  EXPECT_TRUE(0.0f == LIBC_NAMESPACE::logf(1.0f));
+#else
   EXPECT_FP_EQ_ALL_ROUNDING(zero, LIBC_NAMESPACE::logf(1.0f));
+#endif // LIBC_MATH_HAS_SKIP_ACCURATE_PASS
 }
 
 TEST_F(LlvmLibcLogfTest, TrickyInputs) {
@@ -73,7 +83,7 @@ TEST_F(LlvmLibcLogfTest, TrickyInputs) {
   for (int i = 0; i < N; ++i) {
     float x = FPBits(INPUTS[i]).get_val();
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Log, x,
-                                   LIBC_NAMESPACE::logf(x), 0.5);
+                                   LIBC_NAMESPACE::logf(x), TOLERANCE + 0.5);
   }
 }
 
diff --git a/libc/test/src/math/powf_test.cpp b/libc/test/src/math/powf_test.cpp
index 1d7072463e0b6..fe8ef4fa85117 100644
--- a/libc/test/src/math/powf_test.cpp
+++ b/libc/test/src/math/powf_test.cpp
@@ -7,13 +7,19 @@
 //===----------------------------------------------------------------------===//
 
 #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/powf.h"
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
 #include "utils/MPFRWrapper/MPFRUtils.h"
 
-#include "hdr/stdint_proxy.h"
+#ifdef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+#define TOLERANCE 1
+#else
+#define TOLERANCE 0
+#endif // LIBC_MATH_HAS_SKIP_ACCURATE_PASS
 
 using LlvmLibcPowfTest = LIBC_NAMESPACE::testing::FPTest<float>;
 using LIBC_NAMESPACE::testing::tlog;
@@ -42,7 +48,7 @@ TEST_F(LlvmLibcPowfTest, TrickyInputs) {
     float x = INPUTS[i].x;
     float y = INPUTS[i].y;
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Pow, INPUTS[i],
-                                   LIBC_NAMESPACE::powf(x, y), 0.5);
+                                   LIBC_NAMESPACE::powf(x, y), TOLERANCE + 0.5);
   }
 }
 
@@ -88,7 +94,8 @@ TEST_F(LlvmLibcPowfTest, InFloatRange) {
         mpfr::BinaryInput<float> inputs{x, y};
 
         if (!TEST_MPFR_MATCH_ROUNDING_SILENTLY(mpfr::Operation::Pow, inputs,
-                                               result, 0.5, rounding_mode)) {
+                                               result, TOLERANCE + 0.5,
+                                               rounding_mode)) {
           ++fails;
           while (!TEST_MPFR_MATCH_ROUNDING_SILENTLY(
               mpfr::Operation::Pow, inputs, result, tol, rounding_mode)) {
diff --git a/libc/test/src/math/sin_test.cpp b/libc/test/src/math/sin_test.cpp
index 4d5d9ddf464b1..7eac0348ee6d4 100644
--- a/libc/test/src/math/sin_test.cpp
+++ b/libc/test/src/math/sin_test.cpp
@@ -7,11 +7,18 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/__support/FPUtil/FPBits.h"
+#include "src/__support/macros/optimization.h"
 #include "src/math/sin.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 LlvmLibcSinTest = LIBC_NAMESPACE::testing::FPTest<double>;
 
 namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
@@ -46,7 +53,7 @@ TEST_F(LlvmLibcSinTest, TrickyInputs) {
   for (int i = 0; i < N; ++i) {
     double x = INPUTS[i];
     ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Sin, x,
-                                   LIBC_NAMESPACE::sin(x), 0.5);
+                                   LIBC_NAMESPACE::sin(x), TOLERANCE + 0.5);
   }
 }
 
diff --git a/libc/test/src/math/sincos_test.cpp b/libc/test/src/math/sincos_test.cpp
index 09c87153890d0..30bfec646eee9 100644
--- a/libc/test/src/math/sincos_test.cpp
+++ b/libc/test/src/math/sincos_test.cpp
@@ -7,11 +7,18 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/__support/FPUtil/FPBits.h"
+#include "src/__support/macros/optimization.h"
 #include "src/math/sincos.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 LlvmLibcSincosTest = LIBC_NAMESPACE::testing::FPTest<double>;
 
 namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
@@ -26,36 +33,36 @@ using LIBC_NAMESPACE::testing::tlog;
     mpfr::ForceRoundingMode __r1(mpfr::RoundingMode::Nearest);                 \
     if (__r1.success) {                                                        \
       LIBC_NAMESPACE::sincos(input, &sin_x, &cos_x);                           \
-      ASSERT_MPFR_MATCH(mpfr::Operation::Sin, input, sin_x, 0.5,               \
+      ASSERT_MPFR_MATCH(mpfr::Operation::Sin, input, sin_x, TOLERANCE + 0.5,   \
                         mpfr::RoundingMode::Nearest);                          \
-      ASSERT_MPFR_MATCH(mpfr::Operation::Cos, input, cos_x, 0.5,               \
+      ASSERT_MPFR_MATCH(mpfr::Operation::Cos, input, cos_x, TOLERANCE + 0.5,   \
                         mpfr::RoundingMode::Nearest);                          \
     }                                                                          \
                                                                                \
     mpfr::ForceRoundingMode __r2(mpfr::RoundingMode::Upward);                  \
     if (__r2.success) {                                                        \
       LIBC_NAMESPACE::sincos(input, &sin_x, &cos_x);                           \
-      ASSERT_MPFR_MATCH(mpfr::Operation::Sin, input, sin_x, 0.5,               \
+      ASSERT_MPFR_MATCH(mpfr::Operation::Sin, input, sin_x, TOLERANCE + 0.5,   \
                         mpfr::RoundingMode::Upward);                           \
-      ASSERT_MPFR_MATCH(mpfr::Operation::Cos, input, cos_x, 0.5,               \
+      ASSERT_MPFR_MATCH(mpfr::Operation::Cos, input, cos_x, TOLERANCE + 0.5,   \
                         mpfr::RoundingMode::Upward);                           \
     }                                                                          \
                                                                                \
     mpfr::ForceRoundingMode __r3(mpfr::RoundingMode::Downward);                \
     if (__r3.success) {                                                        \
       LIBC_NAMESPACE::sincos(input, &sin_x, &cos_x);                           \
-      ASSERT_MPFR_MATCH(mpfr::Operation::Sin, input, sin_x, 0.5,               \
+      ASSERT_MPFR_MATCH(mpfr::Operation::Sin, input, sin_x, TOLERANCE + 0.5,   \
                         mpfr::RoundingMode::Downward);                         \
-      ASSERT_MPFR_MATCH(mpfr::Operation::Cos, input, cos_x, 0.5,               \
+      ASSERT_MPFR_MATCH(mpfr::Operation::Cos, input, cos_x, TOLERANCE + 0.5,   \
                         mpfr::RoundingMode::Downward);                         \
     }                                                                          \
                                                                                \
     mpfr::ForceRoundingMode __r4(mpfr::RoundingMode::TowardZero);              \
     if (__r4.success) {                                                        \
       LIBC_NAMESPACE::sincos(input, &sin_x, &cos_x);                           \
-      ASSERT_MPFR_MATCH(mpfr::Operation::Sin, input, sin_x, 0.5,               \
+      ASSERT_MPFR_MATCH(mpfr::Operation::Sin, input, sin_x, TOLERANCE + 0.5,   \
                         mpfr::RoundingMode::TowardZero);                       \
-      ASSERT_MPFR_MATCH(mpfr::Operation::Cos, input, cos_x, 0.5,               \
+      ASSERT_MPFR_MATCH(mpfr::Operation::Cos, input, cos_x, TOLERANCE + 0.5,   \
                         mpfr::RoundingMode::TowardZero);                       \
     }                                                                          \
   } while (0)
diff --git a/libc/test/src/math/sincosf_test.cpp b/libc/test/src/math/sincosf_test.cpp
index 87e995db51119..9e6263bb52a67 100644
--- a/libc/test/src/math/sincosf_test.cpp
+++ b/libc/test/src/math/sincosf_test.cpp
@@ -8,14 +8,20 @@
 
 #include "hdr/errno_macros.h"
 #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/sincosf.h"
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
 #include "test/src/math/sdcomp26094.h"
 #include "utils/MPFRWrapper/MPFRUtils.h"
 
-#include "hdr/stdint_proxy.h"
+#ifdef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+#define TOLERANCE 1
+#else
+#define TOLERANCE 0
+#endif // LIBC_MATH_HAS_SKIP_ACCURATE_PASS
 
 using LlvmLibcSinCosfTest = LIBC_NAMESPACE::testing::FPTest<float>;
 
@@ -60,36 +66,36 @@ TEST_F(LlvmLibcSinCosfTest, SpecialNumbers) {
     mpfr::ForceRoundingMode __r1(mpfr::RoundingMode::Nearest);                 \
     if (__r1.success) {                                                        \
       LIBC_NAMESPACE::sincosf(input, &sin, &cos);                              \
-      EXPECT_MPFR_MATCH(mpfr::Operation::Sin, input, sin, 0.5,                 \
+      EXPECT_MPFR_MATCH(mpfr::Operation::Sin, input, sin, TOLERANCE + 0.5,     \
                         mpfr::RoundingMode::Nearest);                          \
-      EXPECT_MPFR_MATCH(mpfr::Operation::Cos, input, cos, 0.5,                 \
+      EXPECT_MPFR_MATCH(mpfr::Operation::Cos, input, cos, TOLERANCE + 0.5,     \
                         mpfr::RoundingMode::Nearest);                          \
     }                                                                          \
                                                                                \
     mpfr::ForceRoundingMode __r2(mpfr::RoundingMode::Upward);                  \
     if (__r2.success) {                                                        \
       LIBC_NAMESPACE::sincosf(input, &sin, &cos);                              \
-      EXPECT_MPFR_MATCH(mpfr::Operation::Sin, input, sin, 0.5,                 \
+      EXPECT_MPFR_MATCH(mpfr::Operation::Sin, input, sin, TOLERANCE + 0.5,     \
                         mpfr::RoundingMode::Upward);                           \
-      EXPECT_MPFR_MATCH(mpfr::Operation::Cos, input, cos, 0.5,                 \
+      EXPECT_MPFR_MATCH(mpfr::Operation::Cos, input, cos, TOLERANCE + 0.5,     \
                         mpfr::RoundingMode::Upward);                           \
     }                                                                          \
                                                                                \
     mpfr::ForceRoundingMode __r3(mpfr::RoundingMode::Downward);                \
     if (__r3.success) {                                                        \
       LIBC_NAMESPACE::sincosf(input, &sin, &cos);                              \
-      EXPECT_MPFR_MATCH(mpfr::Operation::Sin, input, sin, 0.5,                 \
+      EXPECT_MPFR_MATCH(mpfr::Operation::Sin, input, sin, TOLERANCE + 0.5,     \
                         mpfr::RoundingMode::Downward);                         \
-      EXPECT_MPFR_MATCH(mpfr::Operation::Cos, input, cos, 0.5,                 \
+      EXPECT_MPFR_MATCH(mpfr::Operation::Cos, input, cos, TOLERANCE + 0.5,     \
                         mpfr::RoundingMode::Downward);                         \
     }                                                                          \
                                                                                \
     mpfr::ForceRoundingMode __r4(mpfr::RoundingMode::TowardZero);              \
     if (__r4.success) {                                                        \
       LIBC_NAMESPACE::sincosf(input, &sin, &cos);                              \
-      EXPECT_MPFR_MATCH(mpfr::Operation::Sin, input, sin, 0.5,                 \
+      EXPECT_MPFR_MATCH(mpfr::Operation::Sin, input, sin, TOLERANCE + 0.5,     \
                         mpfr::RoundingMode::TowardZero);                       \
-      EXPECT_MPFR_MATCH(mpfr::Operation::Cos, input, cos, 0.5,                 \
+      EXPECT_MPFR_MATCH(mpfr::Operation::Cos, input, cos, TOLERANCE + 0.5,     \
                         mpfr::RoundingMode::TowardZero);                       \
     }                                                                          \
   }
diff --git a/libc/test/src/math/sinf16_test.cpp b/libc/test/src/math/sinf16_test.cpp
index b05501cb0f145..d8e9e02f6b1b2 100644
--- a/libc/test/src/math/sinf16_test.cpp
+++ b/libc/test/src/math/sinf16_test.cpp
@@ -6,11 +6,18 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "src/__support/macros/optimization.h"
 #include "src/math/sinf16.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 LlvmLibcSinf16Test = LIBC_NAMESPACE::testing::FPTest<float16>;
 
 namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
@@ -27,7 +34,7 @@ TEST_F(LlvmLibcSinf16Test, PositiveRange) {
   for (uint16_t v = POS_START; v <= POS_STOP; ++v) {
     float16 x = FPBits(v).get_val();
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Sin, x,
-                                   LIBC_NAMESPACE::sinf16(x), 0.5);
+                                   LIBC_NAMESPACE::sinf16(x), TOLERANCE + 0.5);
   }
 }
 
@@ -35,6 +42,6 @@ TEST_F(LlvmLibcSinf16Test, NegativeRange) {
   for (uint16_t v = NEG_START; v <= NEG_STOP; ++v) {
     float16 x = FPBits(v).get_val();
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Sin, x,
-                                   LIBC_NAMESPACE::sinf16(x), 0.5);
+                                   LIBC_NAMESPACE::sinf16(x), TOLERANCE + 0.5);
   }
 }
diff --git a/libc/test/src/math/sinf_test.cpp b/libc/test/src/math/sinf_test.cpp
index 42de7afa2fb74..516941ba49b9e 100644
--- a/libc/test/src/math/sinf_test.cpp
+++ b/libc/test/src/math/sinf_test.cpp
@@ -8,6 +8,7 @@
 
 #include "hdr/errno_macros.h"
 #include "hdr/math_macros.h"
+#include "hdr/stdint_proxy.h"
 #include "src/__support/FPUtil/FPBits.h"
 #include "src/math/sinf.h"
 #include "test/UnitTest/FPMatcher.h"
@@ -15,7 +16,13 @@
 #include "test/src/math/sdcomp26094.h"
 #include "utils/MPFRWrapper/MPFRUtils.h"
 
-#include "hdr/stdint_proxy.h"
+#ifdef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+#define TOLERANCE 3
+#define FP_ASSERT ASSERT_MPFR_MATCH
+#else
+#define TOLERANCE 0
+#define FP_ASSERT ASSERT_MPFR_MATCH_ALL_ROUNDING
+#endif // LIBC_MATH_HAS_SKIP_ACCURATE_PASS
 
 using LlvmLibcSinfTest = LIBC_NAMESPACE::testing::FPTest<float>;
 
@@ -30,8 +37,13 @@ TEST_F(LlvmLibcSinfTest, SpecialNumbers) {
   EXPECT_FP_EQ(0.0f, LIBC_NAMESPACE::sinf(0.0f));
   EXPECT_MATH_ERRNO(0);
 
+// When accuracy is not required, signed zeros might not be preserved.
+#ifdef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+  EXPECT_TRUE(0.0f == LIBC_NAMESPACE::sinf(-0.0f));
+#else
   EXPECT_FP_EQ(-0.0f, LIBC_NAMESPACE::sinf(-0.0f));
   EXPECT_MATH_ERRNO(0);
+#endif // LIBC_MATH_HAS_SKIP_ACCURATE_PASS
 
   EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::sinf(inf));
   EXPECT_MATH_ERRNO(EDOM);
@@ -47,8 +59,8 @@ TEST_F(LlvmLibcSinfTest, InFloatRange) {
     float x = FPBits(v).get_val();
     if (FPBits(v).is_nan() || FPBits(v).is_inf())
       continue;
-    ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Sin, x,
-                                   LIBC_NAMESPACE::sinf(x), 0.5);
+    FP_ASSERT(mpfr::Operation::Sin, x, LIBC_NAMESPACE::sinf(x),
+              TOLERANCE + 0.5);
   }
 }
 
@@ -95,22 +107,20 @@ TEST_F(LlvmLibcSinfTest, SpecificBitPatterns) {
 
   for (int i = 0; i < N; ++i) {
     float x = FPBits(INPUTS[i]).get_val();
-    EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Sin, x,
-                                   LIBC_NAMESPACE::sinf(x), 0.5);
-    EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Sin, -x,
-                                   LIBC_NAMESPACE::sinf(-x), 0.5);
+    FP_ASSERT(mpfr::Operation::Sin, x, LIBC_NAMESPACE::sinf(x),
+              TOLERANCE + 0.5);
+    FP_ASSERT(mpfr::Operation::Sin, -x, LIBC_NAMESPACE::sinf(-x),
+              TOLERANCE + 0.5);
   }
 }
 
 // For small values, sin(x) is x.
 TEST_F(LlvmLibcSinfTest, SmallValues) {
   float x = FPBits(0x1780'0000U).get_val();
-  EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Sin, x,
-                                 LIBC_NAMESPACE::sinf(x), 0.5);
+  FP_ASSERT(mpfr::Operation::Sin, x, LIBC_NAMESPACE::sinf(x), 0.5);
 
   x = FPBits(0x0040'0000U).get_val();
-  EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Sin, x,
-                                 LIBC_NAMESPACE::sinf(x), 0.5);
+  FP_ASSERT(mpfr::Operation::Sin, x, LIBC_NAMESPACE::sinf(x), 0.5);
 }
 
 // SDCOMP-26094: check sinf in the cases for which the range reducer
@@ -118,7 +128,7 @@ TEST_F(LlvmLibcSinfTest, SmallValues) {
 TEST_F(LlvmLibcSinfTest, SDCOMP_26094) {
   for (uint32_t v : SDCOMP26094_VALUES) {
     float x = FPBits((v)).get_val();
-    EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Sin, x,
-                                   LIBC_NAMESPACE::sinf(x), 0.5);
+    FP_ASSERT(mpfr::Operation::Sin, x, LIBC_NAMESPACE::sinf(x),
+              TOLERANCE + 0.5);
   }
 }
diff --git a/libc/test/src/math/sinhf16_test.cpp b/libc/test/src/math/sinhf16_test.cpp
index a16ab9279c457..04e0730f0efd4 100644
--- a/libc/test/src/math/sinhf16_test.cpp
+++ b/libc/test/src/math/sinhf16_test.cpp
@@ -6,11 +6,18 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "src/__support/macros/optimization.h"
 #include "src/math/sinhf16.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 LlvmLibcSinhf16Test = LIBC_NAMESPACE::testing::FPTest<float16>;
 
 namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
@@ -27,7 +34,7 @@ TEST_F(LlvmLibcSinhf16Test, PositiveRange) {
   for (uint16_t v = POS_START; v <= POS_STOP; ++v) {
     float16 x = FPBits(v).get_val();
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Sinh, x,
-                                   LIBC_NAMESPACE::sinhf16(x), 0.5);
+                                   LIBC_NAMESPACE::sinhf16(x), TOLERANCE + 0.5);
   }
 }
 
@@ -35,6 +42,6 @@ TEST_F(LlvmLibcSinhf16Test, NegativeRange) {
   for (uint16_t v = NEG_START; v <= NEG_STOP; ++v) {
     float16 x = FPBits(v).get_val();
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Sinh, x,
-                                   LIBC_NAMESPACE::sinhf16(x), 0.5);
+                                   LIBC_NAMESPACE::sinhf16(x), TOLERANCE + 0.5);
   }
 }
diff --git a/libc/test/src/math/sinhf_test.cpp b/libc/test/src/math/sinhf_test.cpp
index 6f9ac2fde8278..93a1eecc6186c 100644
--- a/libc/test/src/math/sinhf_test.cpp
+++ b/libc/test/src/math/sinhf_test.cpp
@@ -8,14 +8,20 @@
 
 #include "hdr/errno_macros.h"
 #include "hdr/math_macros.h"
+#include "hdr/stdint_proxy.h"
 #include "src/__support/CPP/array.h"
 #include "src/__support/FPUtil/FPBits.h"
+#include "src/__support/macros/optimization.h"
 #include "src/math/sinhf.h"
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
 #include "utils/MPFRWrapper/MPFRUtils.h"
 
-#include "hdr/stdint_proxy.h"
+#ifdef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+#define TOLERANCE 1
+#else
+#define TOLERANCE 0
+#endif // LIBC_MATH_HAS_SKIP_ACCURATE_PASS
 
 using LlvmLibcSinhfTest = LIBC_NAMESPACE::testing::FPTest<float>;
 
@@ -79,9 +85,9 @@ TEST_F(LlvmLibcSinhfTest, Overflow) {
 TEST_F(LlvmLibcSinhfTest, ExceptionalValues) {
   float x = FPBits(uint32_t(0x3a12'85ffU)).get_val();
   EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Sinh, x,
-                                 LIBC_NAMESPACE::sinhf(x), 0.5);
+                                 LIBC_NAMESPACE::sinhf(x), TOLERANCE + 0.5);
 
   x = -FPBits(uint32_t(0x3a12'85ffU)).get_val();
   EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Sinh, x,
-                                 LIBC_NAMESPACE::sinhf(x), 0.5);
+                                 LIBC_NAMESPACE::sinhf(x), TOLERANCE + 0.5);
 }
diff --git a/libc/test/src/math/smoke/sinf_test.cpp b/libc/test/src/math/smoke/sinf_test.cpp
index b0ba81e650d40..7b671c6cfa067 100644
--- a/libc/test/src/math/smoke/sinf_test.cpp
+++ b/libc/test/src/math/smoke/sinf_test.cpp
@@ -10,6 +10,7 @@
 #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/sinf.h"
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
@@ -26,8 +27,13 @@ TEST_F(LlvmLibcSinfTest, SpecialNumbers) {
   EXPECT_FP_EQ(0.0f, LIBC_NAMESPACE::sinf(0.0f));
   EXPECT_MATH_ERRNO(0);
 
+// When accuracy is not required, signed zeros might not be preserved.
+#ifdef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+  EXPECT_TRUE(0.0f == LIBC_NAMESPACE::sinf(-0.0f));
+#else
   EXPECT_FP_EQ(-0.0f, LIBC_NAMESPACE::sinf(-0.0f));
   EXPECT_MATH_ERRNO(0);
+#endif // LIBC_MATH_HAS_SKIP_ACCURATE_PASS
 
   EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::sinf(inf));
   EXPECT_MATH_ERRNO(EDOM);
diff --git a/libc/test/src/math/tan_test.cpp b/libc/test/src/math/tan_test.cpp
index 12dfc02bac111..62f8994c9143a 100644
--- a/libc/test/src/math/tan_test.cpp
+++ b/libc/test/src/math/tan_test.cpp
@@ -7,11 +7,18 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/__support/FPUtil/FPBits.h"
+#include "src/__support/macros/optimization.h"
 #include "src/math/tan.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 4
+#else
+#define TOLERANCE 0
+#endif // LIBC_MATH_HAS_SKIP_ACCURATE_PASS
+
 using LlvmLibcTanTest = LIBC_NAMESPACE::testing::FPTest<double>;
 
 namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
@@ -53,9 +60,9 @@ TEST_F(LlvmLibcTanTest, TrickyInputs) {
   for (int i = 0; i < N; ++i) {
     double x = INPUTS[i];
     ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Tan, x,
-                                   LIBC_NAMESPACE::tan(x), 0.5);
+                                   LIBC_NAMESPACE::tan(x), TOLERANCE + 0.5);
     ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Tan, -x,
-                                   LIBC_NAMESPACE::tan(-x), 0.5);
+                                   LIBC_NAMESPACE::tan(-x), TOLERANCE + 0.5);
   }
 }
 
@@ -89,7 +96,7 @@ TEST_F(LlvmLibcTanTest, InDoubleRange) {
       ++tested;
 
       if (!TEST_MPFR_MATCH_ROUNDING_SILENTLY(mpfr::Operation::Tan, x, result,
-                                             0.5, rounding_mode)) {
+                                             TOLERANCE + 0.5, rounding_mode)) {
         ++fails;
         while (!TEST_MPFR_MATCH_ROUNDING_SILENTLY(mpfr::Operation::Tan, x,
                                                   result, ulp, rounding_mode)) {
diff --git a/libc/test/src/math/tanf16_test.cpp b/libc/test/src/math/tanf16_test.cpp
index f2e874182efc1..cd4613bfb0ac4 100644
--- a/libc/test/src/math/tanf16_test.cpp
+++ b/libc/test/src/math/tanf16_test.cpp
@@ -6,11 +6,18 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "src/__support/macros/optimization.h"
 #include "src/math/tanf16.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 LlvmLibcTanf16Test = LIBC_NAMESPACE::testing::FPTest<float16>;
 
 namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
@@ -27,7 +34,7 @@ TEST_F(LlvmLibcTanf16Test, PositiveRange) {
   for (uint16_t v = POS_START; v <= POS_STOP; ++v) {
     float16 x = FPBits(v).get_val();
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Tan, x,
-                                   LIBC_NAMESPACE::tanf16(x), 0.5);
+                                   LIBC_NAMESPACE::tanf16(x), TOLERANCE + 0.5);
   }
 }
 
@@ -35,6 +42,6 @@ TEST_F(LlvmLibcTanf16Test, NegativeRange) {
   for (uint16_t v = NEG_START; v <= NEG_STOP; ++v) {
     float16 x = FPBits(v).get_val();
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Tan, x,
-                                   LIBC_NAMESPACE::tanf16(x), 0.5);
+                                   LIBC_NAMESPACE::tanf16(x), TOLERANCE + 0.5);
   }
 }
diff --git a/libc/test/src/math/tanf_test.cpp b/libc/test/src/math/tanf_test.cpp
index 2202bd623f5ed..b384d8cab4ea7 100644
--- a/libc/test/src/math/tanf_test.cpp
+++ b/libc/test/src/math/tanf_test.cpp
@@ -9,12 +9,19 @@
 #include "hdr/errno_macros.h"
 #include "hdr/math_macros.h"
 #include "src/__support/FPUtil/FPBits.h"
+#include "src/__support/macros/optimization.h"
 #include "src/math/tanf.h"
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
 #include "test/src/math/sdcomp26094.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
+
 #include "hdr/stdint_proxy.h"
 
 using LlvmLibcTanfTest = LIBC_NAMESPACE::testing::FPTest<float>;
@@ -114,9 +121,9 @@ TEST_F(LlvmLibcTanfTest, SpecificBitPatterns) {
   for (int i = 0; i < N; ++i) {
     float x = FPBits(INPUTS[i]).get_val();
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Tan, x,
-                                   LIBC_NAMESPACE::tanf(x), 0.5);
+                                   LIBC_NAMESPACE::tanf(x), TOLERANCE + 0.5);
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Tan, -x,
-                                   LIBC_NAMESPACE::tanf(-x), 0.5);
+                                   LIBC_NAMESPACE::tanf(-x), TOLERANCE + 0.5);
   }
 }
 
diff --git a/libc/test/src/math/tanhf16_test.cpp b/libc/test/src/math/tanhf16_test.cpp
index 7124a83f3d7bc..ff796047309bf 100644
--- a/libc/test/src/math/tanhf16_test.cpp
+++ b/libc/test/src/math/tanhf16_test.cpp
@@ -6,11 +6,18 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "src/__support/macros/optimization.h"
 #include "src/math/tanhf16.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 LlvmLibcTanhf16Test = LIBC_NAMESPACE::testing::FPTest<float16>;
 
 namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
@@ -27,7 +34,7 @@ TEST_F(LlvmLibcTanhf16Test, PositiveRange) {
   for (uint16_t v = POS_START; v <= POS_STOP; ++v) {
     float16 x = FPBits(v).get_val();
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Tanh, x,
-                                   LIBC_NAMESPACE::tanhf16(x), 0.5);
+                                   LIBC_NAMESPACE::tanhf16(x), TOLERANCE + 0.5);
   }
 }
 
@@ -35,6 +42,6 @@ TEST_F(LlvmLibcTanhf16Test, NegativeRange) {
   for (uint16_t v = NEG_START; v <= NEG_STOP; ++v) {
     float16 x = FPBits(v).get_val();
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Tanh, x,
-                                   LIBC_NAMESPACE::tanhf16(x), 0.5);
+                                   LIBC_NAMESPACE::tanhf16(x), TOLERANCE + 0.5);
   }
 }
diff --git a/libc/test/src/math/tanpif16_test.cpp b/libc/test/src/math/tanpif16_test.cpp
index 04d1f713574a1..f994781dd84b1 100644
--- a/libc/test/src/math/tanpif16_test.cpp
+++ b/libc/test/src/math/tanpif16_test.cpp
@@ -6,11 +6,18 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "src/__support/macros/optimization.h"
 #include "src/math/tanpif16.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 LlvmLibcTanpif16Test = LIBC_NAMESPACE::testing::FPTest<float16>;
 
 namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
@@ -27,7 +34,8 @@ TEST_F(LlvmLibcTanpif16Test, PositiveRange) {
   for (uint16_t v = POS_START; v <= POS_STOP; ++v) {
     float16 x = FPBits(v).get_val();
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Tanpi, x,
-                                   LIBC_NAMESPACE::tanpif16(x), 0.5);
+                                   LIBC_NAMESPACE::tanpif16(x),
+                                   TOLERANCE + 0.5);
   }
 }
 
@@ -35,6 +43,7 @@ TEST_F(LlvmLibcTanpif16Test, NegativeRange) {
   for (uint16_t v = NEG_START; v <= NEG_STOP; ++v) {
     float16 x = FPBits(v).get_val();
     EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Tanpi, x,
-                                   LIBC_NAMESPACE::tanpif16(x), 0.5);
+                                   LIBC_NAMESPACE::tanpif16(x),
+                                   TOLERANCE + 0.5);
   }
 }



More information about the libc-commits mailing list