Skip to content

Conversation

bassiounix
Copy link
Contributor

@bassiounix bassiounix commented Aug 13, 2025

@llvmbot
Copy link
Member

llvmbot commented Aug 13, 2025

@llvm/pr-subscribers-libc

Author: Muhammad Bassiouni (bassiounix)

Changes

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

19 Files Affected:

  • (modified) libc/shared/math.h (+1)
  • (added) libc/shared/math/coshf.h (+23)
  • (modified) libc/src/__support/math/CMakeLists.txt (+21)
  • (added) libc/src/__support/math/coshf.h (+65)
  • (renamed) libc/src/__support/math/sinhfcoshf_utils.h (+13-13)
  • (modified) libc/src/math/generic/CMakeLists.txt (+8-30)
  • (modified) libc/src/math/generic/acoshf.cpp (-1)
  • (modified) libc/src/math/generic/coshf.cpp (+2-42)
  • (modified) libc/src/math/generic/exp10m1f.cpp (+1-2)
  • (modified) libc/src/math/generic/exp2.cpp (+1-1)
  • (modified) libc/src/math/generic/exp2f_impl.h (+1-2)
  • (modified) libc/src/math/generic/exp2m1f.cpp (+1-2)
  • (modified) libc/src/math/generic/expm1.cpp (-3)
  • (modified) libc/src/math/generic/sinhf.cpp (+3-2)
  • (modified) libc/src/math/generic/tanhf.cpp (+1-1)
  • (modified) libc/test/shared/CMakeLists.txt (+1)
  • (modified) libc/test/shared/shared_math_test.cpp (+1)
  • (modified) libc/test/src/math/explogxf_test.cpp (+2-2)
  • (modified) utils/bazel/llvm-project-overlay/libc/BUILD.bazel (+29-36)
diff --git a/libc/shared/math.h b/libc/shared/math.h
index a7edb0811a380..c582877563f98 100644
--- a/libc/shared/math.h
+++ b/libc/shared/math.h
@@ -35,6 +35,7 @@
 #include "math/cos.h"
 #include "math/cosf.h"
 #include "math/cosf16.h"
+#include "math/coshf.h"
 #include "math/erff.h"
 #include "math/exp.h"
 #include "math/exp10.h"
diff --git a/libc/shared/math/coshf.h b/libc/shared/math/coshf.h
new file mode 100644
index 0000000000000..33c2580630d59
--- /dev/null
+++ b/libc/shared/math/coshf.h
@@ -0,0 +1,23 @@
+//===-- Shared coshf function -----------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_COSHF_H
+#define LLVM_LIBC_SHARED_MATH_COSHF_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/coshf.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::coshf;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_COSHF_H
diff --git a/libc/src/__support/math/CMakeLists.txt b/libc/src/__support/math/CMakeLists.txt
index f4a8ee0fbb41c..e249af93b36c1 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -407,6 +407,18 @@ add_header_library(
     libc.src.__support.macros.properties.types
 )
 
+add_header_library(
+  coshf
+  HDRS
+    coshf.h
+  DEPENDS
+    .sinhfcoshf_utils
+    libc.src.__support.FPUtil.fp_bits
+    libc.src.__support.FPUtil.multiply_add
+    libc.src.__support.FPUtil.rounding_mode
+    libc.src.__support.macros.optimization
+)
+
 add_header_library(
   erff
   HDRS
@@ -726,3 +738,12 @@ add_header_library(
     libc.src.__support.FPUtil.nearest_integer
     libc.src.__support.common
 )
+
+add_header_library(
+  sinhfcoshf_utils
+  HDRS
+    sinhfcoshf_utils.h
+  DEPENDS
+    .exp10f_utils
+    libc.src.__support.FPUtil.multiply_add
+)
diff --git a/libc/src/__support/math/coshf.h b/libc/src/__support/math/coshf.h
new file mode 100644
index 0000000000000..0f233b87c5e2c
--- /dev/null
+++ b/libc/src/__support/math/coshf.h
@@ -0,0 +1,65 @@
+//===-- Implementation header for coshf -------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_COSHF_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_COSHF_H
+
+#include "sinhfcoshf_utils.h"
+#include "src/__support/FPUtil/FEnvImpl.h"
+#include "src/__support/FPUtil/FPBits.h"
+#include "src/__support/FPUtil/rounding_mode.h"
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+LIBC_INLINE static constexpr float coshf(float x) {
+  using namespace sinhfcoshf_internal;
+  using FPBits = typename fputil::FPBits<float>;
+
+  FPBits xbits(x);
+  xbits.set_sign(Sign::POS);
+  x = xbits.get_val();
+
+  uint32_t x_u = xbits.uintval();
+
+  // When |x| >= 90, or x is inf or nan
+  if (LIBC_UNLIKELY(x_u >= 0x42b4'0000U || x_u <= 0x3280'0000U)) {
+    // |x| <= 2^-26
+    if (x_u <= 0x3280'0000U) {
+      return 1.0f + x;
+    }
+
+    if (xbits.is_inf_or_nan())
+      return x + FPBits::inf().get_val();
+
+    int rounding = fputil::quick_get_round();
+    if (LIBC_UNLIKELY(rounding == FE_DOWNWARD || rounding == FE_TOWARDZERO))
+      return FPBits::max_normal().get_val();
+
+    fputil::set_errno_if_required(ERANGE);
+    fputil::raise_except_if_required(FE_OVERFLOW);
+
+    return x + FPBits::inf().get_val();
+  }
+
+  // TODO: We should be able to reduce the latency and reciprocal throughput
+  // further by using a low degree (maybe 3-7 ?) minimax polynomial for small
+  // but not too small inputs, such as |x| < 2^-2, or |x| < 2^-3.
+
+  // cosh(x) = (e^x + e^(-x)) / 2.
+  return static_cast<float>(exp_pm_eval</*is_sinh*/ false>(x));
+}
+
+} // namespace math
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_COSHF_H
diff --git a/libc/src/math/generic/explogxf.h b/libc/src/__support/math/sinhfcoshf_utils.h
similarity index 89%
rename from libc/src/math/generic/explogxf.h
rename to libc/src/__support/math/sinhfcoshf_utils.h
index 72f8da8c72c5e..5f19b81246980 100644
--- a/libc/src/math/generic/explogxf.h
+++ b/libc/src/__support/math/sinhfcoshf_utils.h
@@ -1,4 +1,4 @@
-//===-- Single-precision general exp/log functions ------------------------===//
+//===-- Single-precision general sinhf/coshf functions --------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,21 +6,17 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_LIBC_SRC_MATH_GENERIC_EXPLOGXF_H
-#define LLVM_LIBC_SRC_MATH_GENERIC_EXPLOGXF_H
+#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_SINHFCOSHF_UTILS_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_SINHFCOSHF_UTILS_H
 
-#include "common_constants.h"
-
-#include "src/__support/common.h"
-#include "src/__support/macros/properties/cpu_features.h"
-#include "src/__support/math/acoshf_utils.h"
-#include "src/__support/math/exp10f_utils.h"
-#include "src/__support/math/exp_utils.h"
+#include "exp10f_utils.h"
+#include "src/__support/FPUtil/multiply_add.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
-constexpr int LOG_P1_BITS = 6;
-constexpr int LOG_P1_SIZE = 1 << LOG_P1_BITS;
+namespace math {
+
+namespace sinhfcoshf_internal {
 
 // The function correctly calculates sinh(x) and cosh(x) by calculating exp(x)
 // and exp(-x) simultaneously.
@@ -121,6 +117,10 @@ template <bool is_sinh> LIBC_INLINE double exp_pm_eval(float x) {
   return r;
 }
 
+} // namespace sinhfcoshf_internal
+
+} // namespace math
+
 } // namespace LIBC_NAMESPACE_DECL
 
-#endif // LLVM_LIBC_SRC_MATH_GENERIC_EXPLOGXF_H
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_SINHFCOSHF_UTILS_H
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index 4351f1d7c8a9a..47fc6de1f396d 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -1344,7 +1344,6 @@ add_entrypoint_object(
     ../exp2.h
   DEPENDS
     .common_constants
-    .explogxf
     libc.src.__support.CPP.bit
     libc.src.__support.CPP.optional
     libc.src.__support.FPUtil.dyadic_float
@@ -1357,6 +1356,7 @@ add_entrypoint_object(
     libc.src.__support.FPUtil.triple_double
     libc.src.__support.integer_literals
     libc.src.__support.macros.optimization
+    libc.src.__support.math.exp_utils
     libc.src.errno.errno
 )
 
@@ -1365,7 +1365,6 @@ add_header_library(
   HDRS
     exp2f_impl.h
   DEPENDS
-    .explogxf
     libc.src.__support.FPUtil.except_value_utils
     libc.src.__support.FPUtil.fenv_impl
     libc.src.__support.FPUtil.fp_bits
@@ -1374,6 +1373,7 @@ add_header_library(
     libc.src.__support.FPUtil.polyeval
     libc.src.__support.FPUtil.rounding_mode
     libc.src.__support.macros.optimization
+    libc.src.__support.math.exp10f_utils
     libc.src.__support.common
     libc.src.errno.errno
 )
@@ -1413,7 +1413,6 @@ add_entrypoint_object(
   HDRS
     ../exp2m1f.h
   DEPENDS
-    .explogxf
     libc.src.errno.errno
     libc.src.__support.common
     libc.src.__support.FPUtil.except_value_utils
@@ -1424,6 +1423,7 @@ add_entrypoint_object(
     libc.src.__support.FPUtil.rounding_mode
     libc.src.__support.macros.optimization
     libc.src.__support.macros.properties.cpu_features
+    libc.src.__support.math.exp10f_utils
 )
 
 add_entrypoint_object(
@@ -1488,7 +1488,6 @@ add_entrypoint_object(
   HDRS
     ../exp10m1f.h
   DEPENDS
-    .explogxf
     libc.src.errno.errno
     libc.src.__support.common
     libc.src.__support.FPUtil.except_value_utils
@@ -1498,6 +1497,7 @@ add_entrypoint_object(
     libc.src.__support.FPUtil.polyeval
     libc.src.__support.FPUtil.rounding_mode
     libc.src.__support.macros.optimization
+    libc.src.__support.math.exp10f_utils
 )
 
 add_entrypoint_object(
@@ -1529,14 +1529,11 @@ add_entrypoint_object(
     ../expm1.h
   DEPENDS
     .common_constants
-    .explogxf
     libc.src.__support.CPP.bit
-    libc.src.__support.CPP.optional
     libc.src.__support.FPUtil.dyadic_float
     libc.src.__support.FPUtil.fenv_impl
     libc.src.__support.FPUtil.fp_bits
     libc.src.__support.FPUtil.multiply_add
-    libc.src.__support.FPUtil.nearest_integer
     libc.src.__support.FPUtil.polyeval
     libc.src.__support.FPUtil.rounding_mode
     libc.src.__support.FPUtil.triple_double
@@ -1593,7 +1590,6 @@ add_entrypoint_object(
   DEPENDS
     .common_constants
     .exp2f_impl
-    .explogxf
     libc.src.__support.math.exp10f
     libc.src.__support.CPP.bit
     libc.src.__support.FPUtil.fenv_impl
@@ -3905,19 +3901,6 @@ add_entrypoint_object(
     libc.src.__support.FPUtil.nearest_integer_operations
 )
 
-#TODO: Add errno include to the hyperbolic functions.
-add_header_library(
-  explogxf
-  HDRS
-    explogxf.h
-  DEPENDS
-    .common_constants
-    libc.src.__support.math.exp_utils
-    libc.src.__support.math.acoshf_utils
-    libc.src.__support.macros.properties.cpu_features
-    libc.src.errno.errno
-)
-
 add_entrypoint_object(
   coshf
   SRCS
@@ -3925,11 +3908,7 @@ add_entrypoint_object(
   HDRS
     ../coshf.h
   DEPENDS
-    .explogxf
-    libc.src.__support.FPUtil.fp_bits
-    libc.src.__support.FPUtil.multiply_add
-    libc.src.__support.FPUtil.rounding_mode
-    libc.src.__support.macros.optimization
+    libc.src.__support.math.coshf
 )
 
 add_entrypoint_object(
@@ -3956,10 +3935,10 @@ add_entrypoint_object(
   HDRS
     ../sinhf.h
   DEPENDS
-    .explogxf
     libc.src.__support.FPUtil.fp_bits
     libc.src.__support.FPUtil.rounding_mode
     libc.src.__support.macros.optimization
+    libc.src.__support.math.sinhfcoshf_utils
 )
 
 add_entrypoint_object(
@@ -3973,7 +3952,7 @@ add_entrypoint_object(
     libc.hdr.errno_macros
     libc.hdr.fenv_macros
     libc.src.__support.FPUtil.except_value_utils
-    libc.src.__support.FPUtil.fenv_impl
+    libc.src.__support.FPUtil.fenv_impl 
     libc.src.__support.FPUtil.fp_bits
     libc.src.__support.FPUtil.rounding_mode
     libc.src.__support.macros.optimization
@@ -3986,12 +3965,12 @@ add_entrypoint_object(
   HDRS
     ../tanhf.h
   DEPENDS
-    .explogxf
     libc.src.__support.FPUtil.fp_bits
     libc.src.__support.FPUtil.rounding_mode
     libc.src.__support.FPUtil.multiply_add
     libc.src.__support.FPUtil.polyeval
     libc.src.__support.macros.optimization
+    libc.src.__support.math.exp10f_utils
 )
 
 add_entrypoint_object(
@@ -4022,7 +4001,6 @@ add_entrypoint_object(
   HDRS
     ../acoshf.h
   DEPENDS
-    .explogxf
     libc.src.__support.math.acoshf
 )
 
diff --git a/libc/src/math/generic/acoshf.cpp b/libc/src/math/generic/acoshf.cpp
index 5c04583650e62..c9646329f73d0 100644
--- a/libc/src/math/generic/acoshf.cpp
+++ b/libc/src/math/generic/acoshf.cpp
@@ -7,7 +7,6 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/math/acoshf.h"
-
 #include "src/__support/math/acoshf.h"
 
 namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/math/generic/coshf.cpp b/libc/src/math/generic/coshf.cpp
index 9f87564d524a6..368c0fda32e21 100644
--- a/libc/src/math/generic/coshf.cpp
+++ b/libc/src/math/generic/coshf.cpp
@@ -7,50 +7,10 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/math/coshf.h"
-#include "src/__support/FPUtil/FEnvImpl.h"
-#include "src/__support/FPUtil/FPBits.h"
-#include "src/__support/FPUtil/rounding_mode.h"
-#include "src/__support/macros/config.h"
-#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
-#include "src/math/generic/explogxf.h"
+#include "src/__support/math/coshf.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
-LLVM_LIBC_FUNCTION(float, coshf, (float x)) {
-  using FPBits = typename fputil::FPBits<float>;
-
-  FPBits xbits(x);
-  xbits.set_sign(Sign::POS);
-  x = xbits.get_val();
-
-  uint32_t x_u = xbits.uintval();
-
-  // When |x| >= 90, or x is inf or nan
-  if (LIBC_UNLIKELY(x_u >= 0x42b4'0000U || x_u <= 0x3280'0000U)) {
-    // |x| <= 2^-26
-    if (x_u <= 0x3280'0000U) {
-      return 1.0f + x;
-    }
-
-    if (xbits.is_inf_or_nan())
-      return x + FPBits::inf().get_val();
-
-    int rounding = fputil::quick_get_round();
-    if (LIBC_UNLIKELY(rounding == FE_DOWNWARD || rounding == FE_TOWARDZERO))
-      return FPBits::max_normal().get_val();
-
-    fputil::set_errno_if_required(ERANGE);
-    fputil::raise_except_if_required(FE_OVERFLOW);
-
-    return x + FPBits::inf().get_val();
-  }
-
-  // TODO: We should be able to reduce the latency and reciprocal throughput
-  // further by using a low degree (maybe 3-7 ?) minimax polynomial for small
-  // but not too small inputs, such as |x| < 2^-2, or |x| < 2^-3.
-
-  // cosh(x) = (e^x + e^(-x)) / 2.
-  return static_cast<float>(exp_pm_eval</*is_sinh*/ false>(x));
-}
+LLVM_LIBC_FUNCTION(float, coshf, (float x)) { return math::coshf(x); }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/exp10m1f.cpp b/libc/src/math/generic/exp10m1f.cpp
index 27729104e038d..8589e3fb6639d 100644
--- a/libc/src/math/generic/exp10m1f.cpp
+++ b/libc/src/math/generic/exp10m1f.cpp
@@ -17,8 +17,7 @@
 #include "src/__support/libc_errno.h"
 #include "src/__support/macros/config.h"
 #include "src/__support/macros/optimization.h"
-
-#include "explogxf.h"
+#include "src/__support/math/exp10f_utils.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
diff --git a/libc/src/math/generic/exp2.cpp b/libc/src/math/generic/exp2.cpp
index 726f88b6457fc..154154f2b90c3 100644
--- a/libc/src/math/generic/exp2.cpp
+++ b/libc/src/math/generic/exp2.cpp
@@ -8,7 +8,6 @@
 
 #include "src/math/exp2.h"
 #include "common_constants.h" // Lookup tables EXP2_MID1 and EXP_M2.
-#include "explogxf.h"         // ziv_test_denorm.
 #include "src/__support/CPP/bit.h"
 #include "src/__support/CPP/optional.h"
 #include "src/__support/FPUtil/FEnvImpl.h"
@@ -24,6 +23,7 @@
 #include "src/__support/integer_literals.h"
 #include "src/__support/macros/config.h"
 #include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
+#include "src/__support/math/exp_utils.h"      // ziv_test_denorm.
 
 namespace LIBC_NAMESPACE_DECL {
 
diff --git a/libc/src/math/generic/exp2f_impl.h b/libc/src/math/generic/exp2f_impl.h
index 5c6c2bd415188..b85bb1548019f 100644
--- a/libc/src/math/generic/exp2f_impl.h
+++ b/libc/src/math/generic/exp2f_impl.h
@@ -20,8 +20,7 @@
 #include "src/__support/macros/config.h"
 #include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
 #include "src/__support/macros/properties/cpu_features.h"
-
-#include "explogxf.h"
+#include "src/__support/math/exp10f_utils.h"
 
 namespace LIBC_NAMESPACE_DECL {
 namespace generic {
diff --git a/libc/src/math/generic/exp2m1f.cpp b/libc/src/math/generic/exp2m1f.cpp
index 127c6eaa494d4..16244edb4c583 100644
--- a/libc/src/math/generic/exp2m1f.cpp
+++ b/libc/src/math/generic/exp2m1f.cpp
@@ -18,8 +18,7 @@
 #include "src/__support/macros/config.h"
 #include "src/__support/macros/optimization.h"
 #include "src/__support/macros/properties/cpu_features.h"
-
-#include "explogxf.h"
+#include "src/__support/math/exp10f_utils.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
diff --git a/libc/src/math/generic/expm1.cpp b/libc/src/math/generic/expm1.cpp
index a4dbf38ab27d0..c360554a8af8f 100644
--- a/libc/src/math/generic/expm1.cpp
+++ b/libc/src/math/generic/expm1.cpp
@@ -8,9 +8,7 @@
 
 #include "src/math/expm1.h"
 #include "common_constants.h" // Lookup tables EXP_M1 and EXP_M2.
-#include "explogxf.h"         // ziv_test_denorm.
 #include "src/__support/CPP/bit.h"
-#include "src/__support/CPP/optional.h"
 #include "src/__support/FPUtil/FEnvImpl.h"
 #include "src/__support/FPUtil/FPBits.h"
 #include "src/__support/FPUtil/PolyEval.h"
@@ -18,7 +16,6 @@
 #include "src/__support/FPUtil/dyadic_float.h"
 #include "src/__support/FPUtil/except_value_utils.h"
 #include "src/__support/FPUtil/multiply_add.h"
-#include "src/__support/FPUtil/nearest_integer.h"
 #include "src/__support/FPUtil/rounding_mode.h"
 #include "src/__support/FPUtil/triple_double.h"
 #include "src/__support/common.h"
diff --git a/libc/src/math/generic/sinhf.cpp b/libc/src/math/generic/sinhf.cpp
index 63111f84de141..5f2d0b5d9c71c 100644
--- a/libc/src/math/generic/sinhf.cpp
+++ b/libc/src/math/generic/sinhf.cpp
@@ -12,7 +12,7 @@
 #include "src/__support/FPUtil/rounding_mode.h"
 #include "src/__support/macros/config.h"
 #include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
-#include "src/math/generic/explogxf.h"
+#include "src/__support/math/sinhfcoshf_utils.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
@@ -73,7 +73,8 @@ LLVM_LIBC_FUNCTION(float, sinhf, (float x)) {
   }
 
   // sinh(x) = (e^x - e^(-x)) / 2.
-  return static_cast<float>(exp_pm_eval</*is_sinh*/ true>(x));
+  return static_cast<float>(
+      math::sinhfcoshf_internal::exp_pm_eval</*is_sinh*/ true>(x));
 }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/tanhf.cpp b/libc/src/math/generic/tanhf.cpp
index 32153c3e1c943..0c55047da4826 100644
--- a/libc/src/math/generic/tanhf.cpp
+++ b/libc/src/math/generic/tanhf.cpp
@@ -14,7 +14,7 @@
 #include "src/__support/macros/config.h"
 #include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
 #include "src/__support/macros/properties/cpu_features.h"
-#include "src/math/generic/explogxf.h"
+#include "src/__support/math/exp10f_utils.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
diff --git a/libc/test/shared/CMakeLists.txt b/libc/test/shared/CMakeLists.txt
index a8f17d3acd10d..a36c6b931e71f 100644
--- a/libc/test/shared/CMakeLists.txt
+++ b/libc/test/shared/CMakeLists.txt
@@ -31,6 +31,7 @@ add_fp_unittest(
     libc.src.__support.math.cos
     libc.src.__support.math.cosf
     libc.src.__support.math.cosf16
+    libc.src.__support.math.coshf
     libc.src.__support.math.erff
     libc.src.__support.math.exp
     libc.src.__support.math.exp10
diff --git a/libc/test/shared/shared_math_test.cpp b/libc/test/shared/shared_math_test.cpp
index 971e1b71e658d..e1c6155972420 100644
--- a/libc/test/shared/shared_math_test.cpp
+++ b/libc/test/shared/shared_math_test.cpp
@@ -51,6 +51,7 @@ TEST(LlvmLibcSharedMathTest, AllFloat) {
   EXPECT_FP_EQ(0x0p+0f, LIBC_NAMESPACE::shared::atanhf(0.0f));
   EXPECT_FP_EQ(0x0p+0f, LIBC_NAMESPACE::shared::cbrtf(0.0f));
   EXPECT_FP_EQ(0x1p+0f, LIBC_NAMESPACE::shared::cosf(0.0f));
+  EXPECT_FP_EQ(0x1p+0f, LIBC_NAMESPACE::shared::coshf(0.0f));
   EXPECT_FP_EQ(0x0p+0f, LIBC_NAMESPACE::shared::erff(0.0f));
   EXPECT_FP_EQ(0x1p+0f, LIBC_NAMESPACE::shared::exp10f(0.0f));
   EXPECT_FP_EQ(0x1p+0f, LIBC_NAMESPACE::shared::expf(0.0f));
diff --git a/libc/test/src/math/explogxf_test.cpp b/libc/test/src/math/explogxf_test.cpp
index 49cc96291a392..4d35309238619 100644
--- a/libc/test/src/math/explogxf_test.cpp
+++ b/libc/test/src/math/explogxf_test.cpp
@@ -9,11 +9,11 @@
 #include "hdr/math_macros.h"
 #include "in_float_range_test_helper.h"
 #include "src/__support/FPUtil/FPBits.h"
+#include "src/__support/math/acoshf_utils.h"
+#include "src/__support/math/exp10f_utils.h"
 #include "src/math/fabs.h"
 #include "src/math/fabsf.h"
-#include "src/math/generic/explogxf.h"
 #include "test/UnitTest/FPMatcher.h"
-#include "test/UnitTest/Test.h"
 #include "utils/MPFRWrapper/MPFRUtils.h"
 
 using LlvmLibcExplogfTest = LIBC_NAMESPACE::testing::FPTest<float>;
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index adc0ee8a38e18..3cf928c26e424 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -1953,22 +1953,6 @@ libc_support_library(
     ],
 )
 
-libc_support_library(
-    name = "explogxf",
-    hdrs = ["src/math/generic/explogxf.h"],
-    deps = [
-        ":__support_fputil_fenv_impl",
-        ":__support_fputil_fma",
-        ":__support_fputil_multiply_add",
-        ":__support_fputil_nearest_integer",
-        ":__support_macros_propertie...
[truncated]

Copy link
Contributor Author

bassiounix commented Aug 13, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

Base automatically changed from users/bassiounix/spr/08-09-_libc_math_refactor_cosf16_implementation_to_header-only_in_src___support_math_folder to main August 13, 2025 15:04
@bassiounix bassiounix force-pushed the users/bassiounix/spr/08-13-_libc_math_refactor_coshf_implementation_to_header-only_in_src___support_math_folder branch from 88597da to 0afc37b Compare August 13, 2025 15:06
@bassiounix bassiounix force-pushed the users/bassiounix/spr/08-13-_libc_math_refactor_coshf_implementation_to_header-only_in_src___support_math_folder branch from 0afc37b to 558bae0 Compare August 14, 2025 14:15
@bassiounix bassiounix enabled auto-merge (squash) August 14, 2025 14:18
@bassiounix bassiounix disabled auto-merge August 14, 2025 14:19
@bassiounix bassiounix merged commit 9ddc85f into main Aug 14, 2025
19 checks passed
@bassiounix bassiounix deleted the users/bassiounix/spr/08-13-_libc_math_refactor_coshf_implementation_to_header-only_in_src___support_math_folder branch August 14, 2025 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bazel "Peripheral" support tier build system: utils/bazel libc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants