[libc-commits] [libc] [libc][math] Qualify all math functions to be constexpr (PR #195623)

Muhammad Bassiouni via libc-commits libc-commits at lists.llvm.org
Mon May 4 04:38:59 PDT 2026


https://github.com/bassiounix updated https://github.com/llvm/llvm-project/pull/195623

>From 581c67a582daf7e89ac2faeb4e9a7b23526bc38d Mon Sep 17 00:00:00 2001
From: bassiounix <muhammad.m.bassiouni at gmail.com>
Date: Mon, 4 May 2026 12:37:41 +0300
Subject: [PATCH 1/2] [libc][math] Qualify all math functions to be constexpr

---
 libc/src/__support/FPUtil/FMA.h               |  7 +-
 libc/src/__support/FPUtil/Hypot.h             |  8 +-
 .../__support/FPUtil/ManipulationFunctions.h  |  2 +-
 libc/src/__support/FPUtil/dyadic_float.h      |  2 +-
 libc/src/__support/FPUtil/generic/FMA.h       | 18 ++--
 .../FPUtil/generic/sqrt_80_bit_long_double.h  |  4 +-
 libc/src/__support/FPUtil/nearest_integer.h   |  8 +-
 libc/src/__support/math/asin.h                |  2 +-
 libc/src/__support/math/asinpi.h              |  2 +-
 libc/src/__support/math/asinpif16.h           |  2 +-
 libc/src/__support/math/atan2f16.h            |  2 +-
 libc/src/__support/math/atanbf16.h            |  2 +-
 libc/src/__support/math/atanf_float.h         |  4 +-
 libc/src/__support/math/atanpif16.h           |  2 +-
 libc/src/__support/math/bf16add.h             |  2 +-
 libc/src/__support/math/bf16addf.h            |  2 +-
 libc/src/__support/math/bf16addf128.h         |  2 +-
 libc/src/__support/math/bf16addl.h            |  2 +-
 libc/src/__support/math/bf16div.h             |  2 +-
 libc/src/__support/math/bf16divf.h            |  2 +-
 libc/src/__support/math/bf16divf128.h         |  2 +-
 libc/src/__support/math/bf16divl.h            |  2 +-
 libc/src/__support/math/bf16fma.h             |  2 +-
 libc/src/__support/math/bf16fmaf.h            |  2 +-
 libc/src/__support/math/bf16fmaf128.h         |  3 +-
 libc/src/__support/math/bf16fmal.h            |  3 +-
 libc/src/__support/math/bf16mul.h             |  2 +-
 libc/src/__support/math/bf16mulf.h            |  2 +-
 libc/src/__support/math/bf16mulf128.h         |  2 +-
 libc/src/__support/math/bf16mull.h            |  2 +-
 libc/src/__support/math/bf16sub.h             |  2 +-
 libc/src/__support/math/bf16subf.h            |  2 +-
 libc/src/__support/math/bf16subf128.h         |  2 +-
 libc/src/__support/math/canonicalize.h        |  2 +-
 libc/src/__support/math/canonicalizebf16.h    |  2 +-
 libc/src/__support/math/canonicalizef.h       |  2 +-
 libc/src/__support/math/canonicalizef128.h    |  2 +-
 libc/src/__support/math/canonicalizef16.h     |  2 +-
 libc/src/__support/math/canonicalizel.h       |  2 +-
 libc/src/__support/math/cbrtbf16.h            |  2 +-
 libc/src/__support/math/ceill.h               |  4 +-
 libc/src/__support/math/cos_integer_eval.h    |  2 +-
 libc/src/__support/math/daddf128.h            |  2 +-
 libc/src/__support/math/daddl.h               |  2 +-
 libc/src/__support/math/dfmaf128.h            |  2 +-
 libc/src/__support/math/dfmal.h               |  3 +-
 libc/src/__support/math/dsubf128.h            |  2 +-
 libc/src/__support/math/dsubl.h               |  2 +-
 libc/src/__support/math/erfcf16.h             |  8 +-
 libc/src/__support/math/erff16.h              |  2 +-
 libc/src/__support/math/exp.h                 | 17 ++--
 libc/src/__support/math/exp10f16_utils.h      |  2 +-
 libc/src/__support/math/expf16_utils.h        |  3 +-
 libc/src/__support/math/expxf16_utils.h       |  2 +-
 libc/src/__support/math/f16div.h              |  2 +-
 libc/src/__support/math/f16divf.h             |  2 +-
 libc/src/__support/math/f16divf128.h          |  2 +-
 libc/src/__support/math/f16divl.h             |  2 +-
 libc/src/__support/math/f16fma.h              |  2 +-
 libc/src/__support/math/f16fmaf.h             |  2 +-
 libc/src/__support/math/f16fmaf128.h          |  3 +-
 libc/src/__support/math/f16fmal.h             |  3 +-
 libc/src/__support/math/f16mul.h              |  2 +-
 libc/src/__support/math/f16mulf.h             |  2 +-
 libc/src/__support/math/f16mulf128.h          |  2 +-
 libc/src/__support/math/f16mull.h             |  2 +-
 libc/src/__support/math/f16sqrtf128.h         |  4 +-
 libc/src/__support/math/f16sub.h              |  2 +-
 libc/src/__support/math/f16subf.h             |  2 +-
 libc/src/__support/math/f16subf128.h          |  2 +-
 libc/src/__support/math/f16subl.h             |  2 +-
 libc/src/__support/math/ffma.h                |  2 +-
 libc/src/__support/math/ffmaf128.h            |  2 +-
 libc/src/__support/math/ffmal.h               |  3 +-
 libc/src/__support/math/fma.h                 |  2 +-
 libc/src/__support/math/fmabf16.h             |  2 +-
 libc/src/__support/math/fmaf.h                |  2 +-
 libc/src/__support/math/fmaf16.h              |  2 +-
 libc/src/__support/math/fmaxf.h               |  2 +-
 libc/src/__support/math/hypot.h               |  4 +-
 libc/src/__support/math/hypotbf16.h           |  2 +-
 libc/src/__support/math/hypotf.h              |  4 +-
 libc/src/__support/math/hypotf16.h            |  2 +-
 libc/src/__support/math/log10f16.h            |  2 +-
 libc/src/__support/math/log10p1f16.h          |  2 +-
 libc/src/__support/math/log1pf.h              |  2 +-
 libc/src/__support/math/log2f16.h             |  2 +-
 libc/src/__support/math/log2p1f16.h           |  2 +-
 libc/src/__support/math/logf16.h              |  2 +-
 libc/src/__support/math/nextafter.h           |  2 +-
 libc/src/__support/math/nextafterbf16.h       |  2 +-
 libc/src/__support/math/nextafterf.h          |  2 +-
 libc/src/__support/math/nextafterf128.h       |  2 +-
 libc/src/__support/math/nextafterf16.h        |  2 +-
 libc/src/__support/math/nextafterl.h          |  3 +-
 libc/src/__support/math/nexttoward.h          |  2 +-
 libc/src/__support/math/nexttowardbf16.h      |  2 +-
 libc/src/__support/math/nexttowardf.h         |  2 +-
 libc/src/__support/math/nexttowardf16.h       |  3 +-
 libc/src/__support/math/nexttowardl.h         |  3 +-
 libc/src/__support/math/range_reduction.h     |  5 +-
 .../math/range_reduction_double_common.h      |  2 +-
 .../math/range_reduction_double_fma.h         |  3 +-
 .../math/range_reduction_double_nofma.h       |  3 +-
 libc/src/__support/math/range_reduction_fma.h |  5 +-
 libc/src/__support/math/setpayloadsig.h       |  2 +-
 libc/src/__support/math/setpayloadsigbf16.h   |  2 +-
 libc/src/__support/math/setpayloadsigf.h      |  2 +-
 libc/src/__support/math/setpayloadsigf128.h   |  2 +-
 libc/src/__support/math/setpayloadsigf16.h    |  2 +-
 libc/src/__support/math/setpayloadsigl.h      |  2 +-
 libc/src/__support/math/sin_integer_eval.h    |  2 +-
 libc/src/__support/math/sincos.h              |  2 +-
 .../src/__support/math/sincos_integer_utils.h |  8 +-
 libc/src/__support/math/sincosf_utils.h       | 18 ++--
 libc/src/__support/math/sinf.h                |  2 +-
 libc/src/__support/math/sinf16.h              |  4 +-
 libc/src/__support/math/sinhfcoshf_utils.h    |  8 +-
 libc/src/__support/math/sinpif.h              |  2 +-
 libc/src/__support/math/sinpif16.h            |  2 +-
 libc/src/__support/math/sqrt.h                |  4 +-
 libc/src/__support/math/sqrtbf16.h            |  4 +-
 libc/src/__support/math/sqrtf.h               |  4 +-
 libc/src/__support/math/tanf16.h              |  4 +-
 libc/src/__support/math/tanhf16.h             |  2 +-
 libc/src/__support/math/tanpif16.h            |  2 +-
 .../shared/shared_math_constexpr_test.cpp     | 85 +++++++++++++++++--
 libc/test/shared/shared_math_test.cpp         |  5 --
 128 files changed, 280 insertions(+), 184 deletions(-)

diff --git a/libc/src/__support/FPUtil/FMA.h b/libc/src/__support/FPUtil/FMA.h
index 2cafb4c0974e3..e56de4bb64b9f 100644
--- a/libc/src/__support/FPUtil/FMA.h
+++ b/libc/src/__support/FPUtil/FMA.h
@@ -19,11 +19,11 @@ namespace LIBC_NAMESPACE_DECL {
 namespace fputil {
 
 template <typename OutType, typename InType>
-LIBC_INLINE OutType fma(InType x, InType y, InType z) {
+LIBC_INLINE constexpr OutType fma(InType x, InType y, InType z) {
   return generic::fma<OutType>(x, y, z);
 }
 
-#ifdef LIBC_TARGET_CPU_HAS_FMA
+#if defined(LIBC_TARGET_CPU_HAS_FMA) && !defined(LIBC_HAS_CONSTANT_EVALUATION)
 
 #ifdef LIBC_TARGET_CPU_HAS_FMA_FLOAT
 template <> LIBC_INLINE float fma(float x, float y, float z) {
@@ -44,7 +44,8 @@ template <> LIBC_INLINE double fma(double x, double y, double z) {
 #endif
 }
 #endif // LIBC_TARGET_CPU_HAS_FMA_DOUBLE
-#endif // LIBC_TARGET_CPU_HAS_FMA
+#endif // defined(LIBC_TARGET_CPU_HAS_FMA) &&
+       // !defined(LIBC_HAS_CONSTANT_EVALUATION)
 
 } // namespace fputil
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/__support/FPUtil/Hypot.h b/libc/src/__support/FPUtil/Hypot.h
index 292140065c754..ad718f50772c4 100644
--- a/libc/src/__support/FPUtil/Hypot.h
+++ b/libc/src/__support/FPUtil/Hypot.h
@@ -105,7 +105,7 @@ template <> struct DoubleLength<uint64_t> {
 //   - HYPOT(x, y) is NaN if x or y is NaN.
 //
 template <typename T, cpp::enable_if_t<cpp::is_floating_point_v<T>, int> = 0>
-LIBC_INLINE T hypot(T x, T y) {
+LIBC_INLINE constexpr T hypot(T x, T y) {
   using FPBits_t = FPBits<T>;
   using StorageType = typename FPBits<T>::StorageType;
   using DStorageType = typename DoubleLength<StorageType>::Type;
@@ -151,7 +151,7 @@ LIBC_INLINE T hypot(T x, T y) {
   StorageType a_mant = a_bits.get_mantissa();
   StorageType b_mant = b_bits.get_mantissa();
   DStorageType a_mant_sq, b_mant_sq;
-  bool sticky_bits;
+  bool sticky_bits{};
 
   // Add an extra bit to simplify the final rounding bit computation.
   constexpr StorageType ONE = StorageType(1) << (FPBits_t::FRACTION_LEN + 1);
@@ -159,8 +159,8 @@ LIBC_INLINE T hypot(T x, T y) {
   a_mant <<= 1;
   b_mant <<= 1;
 
-  StorageType leading_one;
-  int y_mant_width;
+  StorageType leading_one{};
+  int y_mant_width{};
   if (a_exp != 0) {
     leading_one = ONE;
     a_mant |= ONE;
diff --git a/libc/src/__support/FPUtil/ManipulationFunctions.h b/libc/src/__support/FPUtil/ManipulationFunctions.h
index 16dc094deda47..bf66a037bc4bc 100644
--- a/libc/src/__support/FPUtil/ManipulationFunctions.h
+++ b/libc/src/__support/FPUtil/ManipulationFunctions.h
@@ -210,7 +210,7 @@ template <typename T, typename U,
                                cpp::is_floating_point_v<U> &&
                                (sizeof(T) <= sizeof(U)),
                            int> = 0>
-LIBC_INLINE constexpr T nextafter(T from, U to) {
+LIBC_INLINE LIBC_CONSTEXPR T nextafter(T from, U to) {
   FPBits<T> from_bits(from);
   if (from_bits.is_nan())
     return from;
diff --git a/libc/src/__support/FPUtil/dyadic_float.h b/libc/src/__support/FPUtil/dyadic_float.h
index 8ce041247716b..975bb9821ebdf 100644
--- a/libc/src/__support/FPUtil/dyadic_float.h
+++ b/libc/src/__support/FPUtil/dyadic_float.h
@@ -343,7 +343,7 @@ template <size_t Bits> struct DyadicFloat {
     bool sticky_bit = !(mantissa & sticky_mask).is_zero();
     int round_and_sticky = int(round_bit) * 2 + int(sticky_bit);
 
-    T d_lo;
+    T d_lo{};
 
     if (LIBC_UNLIKELY(exp_lo <= 0)) {
       // d_lo is denormal, but the output is normal.
diff --git a/libc/src/__support/FPUtil/generic/FMA.h b/libc/src/__support/FPUtil/generic/FMA.h
index 7b46978d0c8af..896d6695ec6f4 100644
--- a/libc/src/__support/FPUtil/generic/FMA.h
+++ b/libc/src/__support/FPUtil/generic/FMA.h
@@ -18,7 +18,7 @@
 #include "src/__support/FPUtil/dyadic_float.h"
 #include "src/__support/FPUtil/rounding_mode.h"
 #include "src/__support/big_int.h"
-#include "src/__support/macros/attributes.h"   // LIBC_INLINE
+#include "src/__support/macros/attributes.h" // LIBC_INLINE
 #include "src/__support/macros/config.h"
 #include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
 
@@ -29,10 +29,10 @@ namespace fputil {
 namespace generic {
 
 template <typename OutType, typename InType>
-LIBC_INLINE cpp::enable_if_t<cpp::is_floating_point_v<OutType> &&
-                                 cpp::is_floating_point_v<InType> &&
-                                 sizeof(OutType) <= sizeof(InType),
-                             OutType>
+LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_floating_point_v<OutType> &&
+                                           cpp::is_floating_point_v<InType> &&
+                                           sizeof(OutType) <= sizeof(InType),
+                                       OutType>
 fma(InType x, InType y, InType z);
 
 // TODO(lntue): Implement fmaf that is correctly rounded to all rounding modes.
@@ -105,10 +105,10 @@ shift_mantissa(int shift_length, T &mant) {
 } // namespace internal
 
 template <typename OutType, typename InType>
-LIBC_INLINE cpp::enable_if_t<cpp::is_floating_point_v<OutType> &&
-                                 cpp::is_floating_point_v<InType> &&
-                                 sizeof(OutType) <= sizeof(InType),
-                             OutType>
+LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_floating_point_v<OutType> &&
+                                           cpp::is_floating_point_v<InType> &&
+                                           sizeof(OutType) <= sizeof(InType),
+                                       OutType>
 fma(InType x, InType y, InType z) {
   using OutFPBits = FPBits<OutType>;
   using OutStorageType = typename OutFPBits::StorageType;
diff --git a/libc/src/__support/FPUtil/generic/sqrt_80_bit_long_double.h b/libc/src/__support/FPUtil/generic/sqrt_80_bit_long_double.h
index 0ba836d17a085..c179353bd5748 100644
--- a/libc/src/__support/FPUtil/generic/sqrt_80_bit_long_double.h
+++ b/libc/src/__support/FPUtil/generic/sqrt_80_bit_long_double.h
@@ -32,12 +32,12 @@ LIBC_INLINE void normalize(int &exponent,
 
 // if constexpr statement in sqrt.h still requires x86::sqrt to be declared
 // even when it's not used.
-LIBC_INLINE long double sqrt(long double x);
+LIBC_INLINE constexpr long double sqrt(long double x);
 
 // Correctly rounded SQRT for all rounding modes.
 // Shift-and-add algorithm.
 #if defined(LIBC_TYPES_LONG_DOUBLE_IS_X86_FLOAT80)
-LIBC_INLINE long double sqrt(long double x) {
+LIBC_INLINE constexpr long double sqrt(long double x) {
   using LDBits = FPBits<long double>;
   using StorageType = typename LDBits::StorageType;
   constexpr StorageType ONE = StorageType(1) << int(LDBits::FRACTION_LEN);
diff --git a/libc/src/__support/FPUtil/nearest_integer.h b/libc/src/__support/FPUtil/nearest_integer.h
index fabd309bd3520..d5b47ea9526eb 100644
--- a/libc/src/__support/FPUtil/nearest_integer.h
+++ b/libc/src/__support/FPUtil/nearest_integer.h
@@ -14,11 +14,13 @@
 #include "src/__support/macros/properties/architectures.h"
 #include "src/__support/macros/properties/cpu_features.h"
 
-#if (defined(LIBC_TARGET_ARCH_IS_X86_64) && defined(LIBC_TARGET_CPU_HAS_SSE4_2))
+#if !defined(LIBC_HAS_CONSTANT_EVALUATION) &&                                  \
+    defined(LIBC_TARGET_ARCH_IS_X86_64) && defined(LIBC_TARGET_CPU_HAS_SSE4_2)
 #include "x86_64/nearest_integer.h"
-#elif (defined(LIBC_TARGET_ARCH_IS_AARCH64) && defined(__ARM_FP))
+#elif !defined(LIBC_HAS_CONSTANT_EVALUATION) &&                                \
+    defined(LIBC_TARGET_ARCH_IS_AARCH64) && defined(__ARM_FP)
 #include "aarch64/nearest_integer.h"
-#elif defined(LIBC_TARGET_ARCH_IS_GPU)
+#elif !defined(LIBC_HAS_CONSTANT_EVALUATION) && defined(LIBC_TARGET_ARCH_IS_GPU)
 
 namespace LIBC_NAMESPACE_DECL {
 namespace fputil {
diff --git a/libc/src/__support/math/asin.h b/libc/src/__support/math/asin.h
index 98e77d0b97454..f3934cc87aa46 100644
--- a/libc/src/__support/math/asin.h
+++ b/libc/src/__support/math/asin.h
@@ -25,7 +25,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE double asin(double x) {
+LIBC_INLINE LIBC_CONSTEXPR double asin(double x) {
   using namespace asin_internal;
   using FPBits = fputil::FPBits<double>;
 
diff --git a/libc/src/__support/math/asinpi.h b/libc/src/__support/math/asinpi.h
index a088ae322ad79..5df60bc4d4dcc 100644
--- a/libc/src/__support/math/asinpi.h
+++ b/libc/src/__support/math/asinpi.h
@@ -25,7 +25,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE double asinpi(double x) {
+LIBC_INLINE LIBC_CONSTEXPR double asinpi(double x) {
   using namespace asin_internal;
   using FPBits = fputil::FPBits<double>;
 
diff --git a/libc/src/__support/math/asinpif16.h b/libc/src/__support/math/asinpif16.h
index 7aefc35f82d01..f6e23d2f50d0f 100644
--- a/libc/src/__support/math/asinpif16.h
+++ b/libc/src/__support/math/asinpif16.h
@@ -27,7 +27,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE float16 asinpif16(float16 x) {
+LIBC_INLINE LIBC_CONSTEXPR float16 asinpif16(float16 x) {
   using FPBits = fputil::FPBits<float16>;
 
   FPBits xbits(x);
diff --git a/libc/src/__support/math/atan2f16.h b/libc/src/__support/math/atan2f16.h
index 297167a429d9f..ccdf7ddf7ae6c 100644
--- a/libc/src/__support/math/atan2f16.h
+++ b/libc/src/__support/math/atan2f16.h
@@ -25,7 +25,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE float16 atan2f16(float16 y, float16 x) {
+LIBC_INLINE LIBC_CONSTEXPR float16 atan2f16(float16 y, float16 x) {
   using namespace inv_trigf_utils_internal;
   using FPBits = fputil::FPBits<float16>;
 
diff --git a/libc/src/__support/math/atanbf16.h b/libc/src/__support/math/atanbf16.h
index 563b8325b8428..0584a1e01eebb 100644
--- a/libc/src/__support/math/atanbf16.h
+++ b/libc/src/__support/math/atanbf16.h
@@ -22,7 +22,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE bfloat16 atanbf16(bfloat16 x) {
+LIBC_INLINE LIBC_CONSTEXPR bfloat16 atanbf16(bfloat16 x) {
   // Generated by Sollya using the following command:
   // > display = hexadecimal;
   // > round(pi/2, SG, RN);
diff --git a/libc/src/__support/math/atanf_float.h b/libc/src/__support/math/atanf_float.h
index 56db2ad2955e6..fe61e9e3741fd 100644
--- a/libc/src/__support/math/atanf_float.h
+++ b/libc/src/__support/math/atanf_float.h
@@ -66,7 +66,7 @@ LIBC_INLINE_VAR constexpr float ATANF_REDUCED_ARG[17] = {
 // Approximating atan( u / (1 + u * k/16) )
 //   atan( u / (1 + u * k/16) ) / u ~ 1 - k/16 * u + (k^2/256 - 1/3) * u^2 +
 //                                    + (k/16 - (k/16)^3) * u^3 + O(u^4)
-LIBC_INLINE float atanf_eval(float u, float k_over_16) {
+LIBC_INLINE LIBC_CONSTEXPR float atanf_eval(float u, float k_over_16) {
   // (k/16)^2
   float c2 = k_over_16 * k_over_16;
   // -(k/16)^3
@@ -85,7 +85,7 @@ LIBC_INLINE float atanf_eval(float u, float k_over_16) {
 // There are several range reduction steps we can take for atan2(y, x) as
 // follow:
 
-LIBC_INLINE float atanf(float x) {
+LIBC_INLINE LIBC_CONSTEXPR float atanf(float x) {
   using namespace atanf_internal;
   using FPBits = typename fputil::FPBits<float>;
   using FPBits = typename fputil::FPBits<float>;
diff --git a/libc/src/__support/math/atanpif16.h b/libc/src/__support/math/atanpif16.h
index e0eaff6678fc5..e8547de8d84af 100644
--- a/libc/src/__support/math/atanpif16.h
+++ b/libc/src/__support/math/atanpif16.h
@@ -73,7 +73,7 @@ namespace math {
 //      g(x)'s primary range of accuracy (i.e., if 0.5 < 1/|x| <= 1), the rule
 //      from Case 2 must be applied recursively to 1/|x|.
 
-LIBC_INLINE float16 atanpif16(float16 x) {
+LIBC_INLINE LIBC_CONSTEXPR float16 atanpif16(float16 x) {
   using FPBits = fputil::FPBits<float16>;
 
   FPBits xbits(x);
diff --git a/libc/src/__support/math/bf16add.h b/libc/src/__support/math/bf16add.h
index 7d7a24d9bc134..2fe6e33922fa3 100644
--- a/libc/src/__support/math/bf16add.h
+++ b/libc/src/__support/math/bf16add.h
@@ -16,7 +16,7 @@
 namespace LIBC_NAMESPACE_DECL {
 namespace math {
 
-LIBC_INLINE bfloat16 bf16add(double x, double y) {
+LIBC_INLINE constexpr bfloat16 bf16add(double x, double y) {
   return fputil::generic::add<bfloat16>(x, y);
 }
 
diff --git a/libc/src/__support/math/bf16addf.h b/libc/src/__support/math/bf16addf.h
index 28a836030d127..658686ea120f6 100644
--- a/libc/src/__support/math/bf16addf.h
+++ b/libc/src/__support/math/bf16addf.h
@@ -16,7 +16,7 @@
 namespace LIBC_NAMESPACE_DECL {
 namespace math {
 
-LIBC_INLINE bfloat16 bf16addf(float x, float y) {
+LIBC_INLINE constexpr bfloat16 bf16addf(float x, float y) {
   return fputil::generic::add<bfloat16>(x, y);
 }
 
diff --git a/libc/src/__support/math/bf16addf128.h b/libc/src/__support/math/bf16addf128.h
index 2bd1d10e38d7d..5af5658b371a3 100644
--- a/libc/src/__support/math/bf16addf128.h
+++ b/libc/src/__support/math/bf16addf128.h
@@ -20,7 +20,7 @@
 namespace LIBC_NAMESPACE_DECL {
 namespace math {
 
-LIBC_INLINE bfloat16 bf16addf128(float128 x, float128 y) {
+LIBC_INLINE constexpr bfloat16 bf16addf128(float128 x, float128 y) {
   return fputil::generic::add<bfloat16>(x, y);
 }
 
diff --git a/libc/src/__support/math/bf16addl.h b/libc/src/__support/math/bf16addl.h
index f9e27cb48ea09..940c74aef2867 100644
--- a/libc/src/__support/math/bf16addl.h
+++ b/libc/src/__support/math/bf16addl.h
@@ -16,7 +16,7 @@
 namespace LIBC_NAMESPACE_DECL {
 namespace math {
 
-LIBC_INLINE bfloat16 bf16addl(long double x, long double y) {
+LIBC_INLINE constexpr bfloat16 bf16addl(long double x, long double y) {
   return fputil::generic::add<bfloat16>(x, y);
 }
 
diff --git a/libc/src/__support/math/bf16div.h b/libc/src/__support/math/bf16div.h
index 060105b88cd11..e8adc3c379a25 100644
--- a/libc/src/__support/math/bf16div.h
+++ b/libc/src/__support/math/bf16div.h
@@ -16,7 +16,7 @@
 namespace LIBC_NAMESPACE_DECL {
 namespace math {
 
-LIBC_INLINE bfloat16 bf16div(double x, double y) {
+LIBC_INLINE constexpr bfloat16 bf16div(double x, double y) {
   return fputil::generic::div<bfloat16>(x, y);
 }
 
diff --git a/libc/src/__support/math/bf16divf.h b/libc/src/__support/math/bf16divf.h
index 0e201f8a124ed..ad5cb57aac828 100644
--- a/libc/src/__support/math/bf16divf.h
+++ b/libc/src/__support/math/bf16divf.h
@@ -17,7 +17,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE bfloat16 bf16divf(float x, float y) {
+LIBC_INLINE constexpr bfloat16 bf16divf(float x, float y) {
   return fputil::generic::div<bfloat16>(x, y);
 }
 
diff --git a/libc/src/__support/math/bf16divf128.h b/libc/src/__support/math/bf16divf128.h
index 8ed5335099e71..ad2b0f2fb57df 100644
--- a/libc/src/__support/math/bf16divf128.h
+++ b/libc/src/__support/math/bf16divf128.h
@@ -21,7 +21,7 @@
 namespace LIBC_NAMESPACE_DECL {
 namespace math {
 
-LIBC_INLINE bfloat16 bf16divf128(float128 x, float128 y) {
+LIBC_INLINE constexpr bfloat16 bf16divf128(float128 x, float128 y) {
   return fputil::generic::div<bfloat16>(x, y);
 }
 
diff --git a/libc/src/__support/math/bf16divl.h b/libc/src/__support/math/bf16divl.h
index ec5a9244b98d6..b6283c386be54 100644
--- a/libc/src/__support/math/bf16divl.h
+++ b/libc/src/__support/math/bf16divl.h
@@ -16,7 +16,7 @@
 namespace LIBC_NAMESPACE_DECL {
 namespace math {
 
-LIBC_INLINE bfloat16 bf16divl(long double x, long double y) {
+LIBC_INLINE constexpr bfloat16 bf16divl(long double x, long double y) {
   return fputil::generic::div<bfloat16>(x, y);
 }
 
diff --git a/libc/src/__support/math/bf16fma.h b/libc/src/__support/math/bf16fma.h
index da88d5753f6bb..83fea3cd90d79 100644
--- a/libc/src/__support/math/bf16fma.h
+++ b/libc/src/__support/math/bf16fma.h
@@ -16,7 +16,7 @@
 namespace LIBC_NAMESPACE_DECL {
 namespace math {
 
-LIBC_INLINE bfloat16 bf16fma(double x, double y, double z) {
+LIBC_INLINE constexpr bfloat16 bf16fma(double x, double y, double z) {
   return fputil::fma<bfloat16>(x, y, z);
 }
 
diff --git a/libc/src/__support/math/bf16fmaf.h b/libc/src/__support/math/bf16fmaf.h
index a7072bcb18418..5612c64409ac3 100644
--- a/libc/src/__support/math/bf16fmaf.h
+++ b/libc/src/__support/math/bf16fmaf.h
@@ -16,7 +16,7 @@
 namespace LIBC_NAMESPACE_DECL {
 namespace math {
 
-LIBC_INLINE bfloat16 bf16fmaf(float x, float y, float z) {
+LIBC_INLINE LIBC_CONSTEXPR bfloat16 bf16fmaf(float x, float y, float z) {
   return fputil::fma<bfloat16>(x, y, z);
 }
 
diff --git a/libc/src/__support/math/bf16fmaf128.h b/libc/src/__support/math/bf16fmaf128.h
index 46a72b1646d2b..916357e054a52 100644
--- a/libc/src/__support/math/bf16fmaf128.h
+++ b/libc/src/__support/math/bf16fmaf128.h
@@ -20,7 +20,8 @@
 namespace LIBC_NAMESPACE_DECL {
 namespace math {
 
-LIBC_INLINE bfloat16 bf16fmaf128(float128 x, float128 y, float128 z) {
+LIBC_INLINE LIBC_CONSTEXPR bfloat16 bf16fmaf128(float128 x, float128 y,
+                                                float128 z) {
   return fputil::fma<bfloat16>(x, y, z);
 }
 
diff --git a/libc/src/__support/math/bf16fmal.h b/libc/src/__support/math/bf16fmal.h
index 93a04d0ec8fac..da559936c5f80 100644
--- a/libc/src/__support/math/bf16fmal.h
+++ b/libc/src/__support/math/bf16fmal.h
@@ -16,7 +16,8 @@
 namespace LIBC_NAMESPACE_DECL {
 namespace math {
 
-LIBC_INLINE bfloat16 bf16fmal(long double x, long double y, long double z) {
+LIBC_INLINE LIBC_CONSTEXPR bfloat16 bf16fmal(long double x, long double y,
+                                             long double z) {
   return fputil::fma<bfloat16>(x, y, z);
 }
 
diff --git a/libc/src/__support/math/bf16mul.h b/libc/src/__support/math/bf16mul.h
index f4f6943e17a84..00aec7bd33731 100644
--- a/libc/src/__support/math/bf16mul.h
+++ b/libc/src/__support/math/bf16mul.h
@@ -16,7 +16,7 @@
 namespace LIBC_NAMESPACE_DECL {
 namespace math {
 
-LIBC_INLINE bfloat16 bf16mul(double x, double y) {
+LIBC_INLINE constexpr bfloat16 bf16mul(double x, double y) {
   return fputil::generic::mul<bfloat16>(x, y);
 }
 
diff --git a/libc/src/__support/math/bf16mulf.h b/libc/src/__support/math/bf16mulf.h
index 16f2129ef4a5c..50ab51d10debe 100644
--- a/libc/src/__support/math/bf16mulf.h
+++ b/libc/src/__support/math/bf16mulf.h
@@ -16,7 +16,7 @@
 namespace LIBC_NAMESPACE_DECL {
 namespace math {
 
-LIBC_INLINE bfloat16 bf16mulf(float x, float y) {
+LIBC_INLINE constexpr bfloat16 bf16mulf(float x, float y) {
   return fputil::generic::mul<bfloat16>(x, y);
 }
 
diff --git a/libc/src/__support/math/bf16mulf128.h b/libc/src/__support/math/bf16mulf128.h
index 4cc9314744ce7..5b44979dc50a7 100644
--- a/libc/src/__support/math/bf16mulf128.h
+++ b/libc/src/__support/math/bf16mulf128.h
@@ -20,7 +20,7 @@
 namespace LIBC_NAMESPACE_DECL {
 namespace math {
 
-LIBC_INLINE bfloat16 bf16mulf128(float128 x, float128 y) {
+LIBC_INLINE constexpr bfloat16 bf16mulf128(float128 x, float128 y) {
   return fputil::generic::mul<bfloat16>(x, y);
 }
 
diff --git a/libc/src/__support/math/bf16mull.h b/libc/src/__support/math/bf16mull.h
index 52b8e3be72baf..52b7524eff937 100644
--- a/libc/src/__support/math/bf16mull.h
+++ b/libc/src/__support/math/bf16mull.h
@@ -16,7 +16,7 @@
 namespace LIBC_NAMESPACE_DECL {
 namespace math {
 
-LIBC_INLINE bfloat16 bf16mull(long double x, long double y) {
+LIBC_INLINE constexpr bfloat16 bf16mull(long double x, long double y) {
   return fputil::generic::mul<bfloat16>(x, y);
 }
 
diff --git a/libc/src/__support/math/bf16sub.h b/libc/src/__support/math/bf16sub.h
index a6aa1dfd6e652..ad402f0423f00 100644
--- a/libc/src/__support/math/bf16sub.h
+++ b/libc/src/__support/math/bf16sub.h
@@ -17,7 +17,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE bfloat16 bf16sub(double x, double y) {
+LIBC_INLINE constexpr bfloat16 bf16sub(double x, double y) {
   return fputil::generic::sub<bfloat16>(x, y);
 }
 
diff --git a/libc/src/__support/math/bf16subf.h b/libc/src/__support/math/bf16subf.h
index 347626f3eaf11..3e5cf1ea6bba5 100644
--- a/libc/src/__support/math/bf16subf.h
+++ b/libc/src/__support/math/bf16subf.h
@@ -17,7 +17,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE bfloat16 bf16subf(float x, float y) {
+LIBC_INLINE constexpr bfloat16 bf16subf(float x, float y) {
   return fputil::generic::sub<bfloat16>(x, y);
 }
 
diff --git a/libc/src/__support/math/bf16subf128.h b/libc/src/__support/math/bf16subf128.h
index 51e42118451c9..fc58b848bb069 100644
--- a/libc/src/__support/math/bf16subf128.h
+++ b/libc/src/__support/math/bf16subf128.h
@@ -21,7 +21,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE bfloat16 bf16subf128(float128 x, float128 y) {
+LIBC_INLINE constexpr bfloat16 bf16subf128(float128 x, float128 y) {
   return fputil::generic::sub<bfloat16>(x, y);
 }
 
diff --git a/libc/src/__support/math/canonicalize.h b/libc/src/__support/math/canonicalize.h
index e7c60d4026bce..b72161c47ec37 100644
--- a/libc/src/__support/math/canonicalize.h
+++ b/libc/src/__support/math/canonicalize.h
@@ -16,7 +16,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE int canonicalize(double *cx, const double *x) {
+LIBC_INLINE constexpr int canonicalize(double *cx, const double *x) {
   return fputil::canonicalize(*cx, *x);
 }
 
diff --git a/libc/src/__support/math/canonicalizebf16.h b/libc/src/__support/math/canonicalizebf16.h
index cc6abd40973e7..013d2cc4a7d3b 100644
--- a/libc/src/__support/math/canonicalizebf16.h
+++ b/libc/src/__support/math/canonicalizebf16.h
@@ -17,7 +17,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE int canonicalizebf16(bfloat16 *cx, const bfloat16 *x) {
+LIBC_INLINE constexpr int canonicalizebf16(bfloat16 *cx, const bfloat16 *x) {
   return fputil::canonicalize(*cx, *x);
 }
 
diff --git a/libc/src/__support/math/canonicalizef.h b/libc/src/__support/math/canonicalizef.h
index da166064219d9..a6c28e5384fdf 100644
--- a/libc/src/__support/math/canonicalizef.h
+++ b/libc/src/__support/math/canonicalizef.h
@@ -16,7 +16,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE int canonicalizef(float *cx, const float *x) {
+LIBC_INLINE constexpr int canonicalizef(float *cx, const float *x) {
   return fputil::canonicalize(*cx, *x);
 }
 
diff --git a/libc/src/__support/math/canonicalizef128.h b/libc/src/__support/math/canonicalizef128.h
index 8b4905353ddfa..69fd62b158900 100644
--- a/libc/src/__support/math/canonicalizef128.h
+++ b/libc/src/__support/math/canonicalizef128.h
@@ -20,7 +20,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE int canonicalizef128(float128 *cx, const float128 *x) {
+LIBC_INLINE constexpr int canonicalizef128(float128 *cx, const float128 *x) {
   return fputil::canonicalize(*cx, *x);
 }
 
diff --git a/libc/src/__support/math/canonicalizef16.h b/libc/src/__support/math/canonicalizef16.h
index b7f44caa8ce3b..d2b695cb72537 100644
--- a/libc/src/__support/math/canonicalizef16.h
+++ b/libc/src/__support/math/canonicalizef16.h
@@ -20,7 +20,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE int canonicalizef16(float16 *cx, const float16 *x) {
+LIBC_INLINE constexpr int canonicalizef16(float16 *cx, const float16 *x) {
   return fputil::canonicalize(*cx, *x);
 }
 
diff --git a/libc/src/__support/math/canonicalizel.h b/libc/src/__support/math/canonicalizel.h
index fb69352fa1fb2..96123713fd303 100644
--- a/libc/src/__support/math/canonicalizel.h
+++ b/libc/src/__support/math/canonicalizel.h
@@ -16,7 +16,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE int canonicalizel(long double *cx, const long double *x) {
+LIBC_INLINE constexpr int canonicalizel(long double *cx, const long double *x) {
   return fputil::canonicalize(*cx, *x);
 }
 
diff --git a/libc/src/__support/math/cbrtbf16.h b/libc/src/__support/math/cbrtbf16.h
index 75a08a32edfa1..aea71ca0a533e 100644
--- a/libc/src/__support/math/cbrtbf16.h
+++ b/libc/src/__support/math/cbrtbf16.h
@@ -16,7 +16,7 @@
 namespace LIBC_NAMESPACE_DECL {
 namespace math {
 
-LIBC_INLINE bfloat16 cbrtbf16(bfloat16 x) {
+LIBC_INLINE constexpr bfloat16 cbrtbf16(bfloat16 x) {
   return fputil::cast<bfloat16>(math::cbrtf(static_cast<float>(x)));
 }
 
diff --git a/libc/src/__support/math/ceill.h b/libc/src/__support/math/ceill.h
index b6b216a5b3489..3b3db1ddcddc5 100644
--- a/libc/src/__support/math/ceill.h
+++ b/libc/src/__support/math/ceill.h
@@ -16,7 +16,9 @@ namespace LIBC_NAMESPACE_DECL {
 namespace math {
 
 // TODO(issue#185232): Mark as constexpr once the refactor is done.
-LIBC_INLINE long double ceill(long double x) { return fputil::ceil(x); }
+LIBC_INLINE constexpr long double ceill(long double x) {
+  return fputil::ceil(x);
+}
 
 } // namespace math
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/__support/math/cos_integer_eval.h b/libc/src/__support/math/cos_integer_eval.h
index 8268929f3932a..8a455c475e79e 100644
--- a/libc/src/__support/math/cos_integer_eval.h
+++ b/libc/src/__support/math/cos_integer_eval.h
@@ -23,7 +23,7 @@ namespace math {
 
 namespace integer_only {
 
-LIBC_INLINE double cos(double x) {
+LIBC_INLINE constexpr double cos(double x) {
   using FPBits = typename fputil::FPBits<double>;
   FPBits xbits(x);
 
diff --git a/libc/src/__support/math/daddf128.h b/libc/src/__support/math/daddf128.h
index 3937250e5c6bc..0f6aa85c32268 100644
--- a/libc/src/__support/math/daddf128.h
+++ b/libc/src/__support/math/daddf128.h
@@ -19,7 +19,7 @@
 namespace LIBC_NAMESPACE_DECL {
 namespace math {
 
-LIBC_INLINE double daddf128(float128 x, float128 y) {
+LIBC_INLINE constexpr double daddf128(float128 x, float128 y) {
   return fputil::generic::add<double>(x, y);
 }
 
diff --git a/libc/src/__support/math/daddl.h b/libc/src/__support/math/daddl.h
index e8bec7b975fb7..1e587446a82a7 100644
--- a/libc/src/__support/math/daddl.h
+++ b/libc/src/__support/math/daddl.h
@@ -15,7 +15,7 @@
 namespace LIBC_NAMESPACE_DECL {
 namespace math {
 
-LIBC_INLINE double daddl(long double x, long double y) {
+LIBC_INLINE constexpr double daddl(long double x, long double y) {
   return fputil::generic::add<double>(x, y);
 }
 
diff --git a/libc/src/__support/math/dfmaf128.h b/libc/src/__support/math/dfmaf128.h
index 54c8761af85f8..4be6630916c32 100644
--- a/libc/src/__support/math/dfmaf128.h
+++ b/libc/src/__support/math/dfmaf128.h
@@ -20,7 +20,7 @@
 namespace LIBC_NAMESPACE_DECL {
 namespace math {
 
-LIBC_INLINE double dfmaf128(float128 x, float128 y, float128 z) {
+LIBC_INLINE LIBC_CONSTEXPR double dfmaf128(float128 x, float128 y, float128 z) {
   return fputil::fma<double>(x, y, z);
 }
 
diff --git a/libc/src/__support/math/dfmal.h b/libc/src/__support/math/dfmal.h
index 0331d59a2c962..2fa79bb6ff0e3 100644
--- a/libc/src/__support/math/dfmal.h
+++ b/libc/src/__support/math/dfmal.h
@@ -16,7 +16,8 @@
 namespace LIBC_NAMESPACE_DECL {
 namespace math {
 
-LIBC_INLINE double dfmal(long double x, long double y, long double z) {
+LIBC_INLINE LIBC_CONSTEXPR double dfmal(long double x, long double y,
+                                        long double z) {
   return fputil::fma<double>(x, y, z);
 }
 
diff --git a/libc/src/__support/math/dsubf128.h b/libc/src/__support/math/dsubf128.h
index e49c64a88b296..db47024e702d0 100644
--- a/libc/src/__support/math/dsubf128.h
+++ b/libc/src/__support/math/dsubf128.h
@@ -19,7 +19,7 @@
 namespace LIBC_NAMESPACE_DECL {
 namespace math {
 
-LIBC_INLINE double dsubf128(float128 x, float128 y) {
+LIBC_INLINE constexpr double dsubf128(float128 x, float128 y) {
   return fputil::generic::sub<double>(x, y);
 }
 
diff --git a/libc/src/__support/math/dsubl.h b/libc/src/__support/math/dsubl.h
index f56e253af9aa1..a82a05214f620 100644
--- a/libc/src/__support/math/dsubl.h
+++ b/libc/src/__support/math/dsubl.h
@@ -15,7 +15,7 @@
 namespace LIBC_NAMESPACE_DECL {
 namespace math {
 
-LIBC_INLINE double dsubl(long double x, long double y) {
+LIBC_INLINE constexpr double dsubl(long double x, long double y) {
   return fputil::generic::sub<double>(x, y);
 }
 
diff --git a/libc/src/__support/math/erfcf16.h b/libc/src/__support/math/erfcf16.h
index 6fc37d7467de7..32fbc069dfcf8 100644
--- a/libc/src/__support/math/erfcf16.h
+++ b/libc/src/__support/math/erfcf16.h
@@ -25,7 +25,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE float16 erfcf16(float16 x) {
+LIBC_INLINE LIBC_CONSTEXPR float16 erfcf16(float16 x) {
   // Polynomials approximating erfc(|x|) on ( k/2, (k+1)/2 ) generated by
   // Sollya with: > P = fpminimax(erfc(x), [|0, 1, 2, 3, 4, 5, 6, 7|], [|D...|],
   //                             [k/2, (k+1)/2]);
@@ -58,9 +58,9 @@ LIBC_INLINE float16 erfcf16(float16 x) {
        0x1.a7c5af0484892p-12, -0x1.ea82a062010c3p-17},
   };
 
-  static constexpr size_t N_ERFCF16_EXCEPTS = 3;
-  static constexpr fputil::ExceptValues<float16, N_ERFCF16_EXCEPTS>
-      ERFCF16_EXCEPTS = {{
+  constexpr size_t N_ERFCF16_EXCEPTS = 3;
+  constexpr fputil::ExceptValues<float16, N_ERFCF16_EXCEPTS> ERFCF16_EXCEPTS = {
+      {
           // (input, RZ output, RU offset, RD offset, RN offset)
           // x = 0x0.000216, erfc(x) = 0x1.000
           {0x0B17, 0x3BFF, 1, 0, 0},
diff --git a/libc/src/__support/math/erff16.h b/libc/src/__support/math/erff16.h
index 8e3a92c092e22..8bb852289a581 100644
--- a/libc/src/__support/math/erff16.h
+++ b/libc/src/__support/math/erff16.h
@@ -24,7 +24,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE float16 erff16(float16 x) {
+LIBC_INLINE LIBC_CONSTEXPR float16 erff16(float16 x) {
 
   // Polynomials approximating erf(x)/x on ( k/8, (k + 1)/8 ) generated by
   // Sollya with: > P = fpminimax(erf(x)/x, [|0, 2, 4, 6, 8, 10, 12, 14|],
diff --git a/libc/src/__support/math/exp.h b/libc/src/__support/math/exp.h
index 8444a59bdf999..5e5758832977d 100644
--- a/libc/src/__support/math/exp.h
+++ b/libc/src/__support/math/exp.h
@@ -69,7 +69,7 @@ LIBC_INLINE_VAR constexpr double MLOG_2_EXP2_M12_LO = 0x1.b0e2633fe0685p-79;
 // Return expm1(dx) / x ~ 1 + dx / 2 + dx^2 / 6 + dx^3 / 24.
 // For |dx| < 2^-13 + 2^-30:
 //   | output - expm1(dx) / dx | < 2^-51.
-LIBC_INLINE double poly_approx_d(double dx) {
+LIBC_INLINE LIBC_CONSTEXPR double poly_approx_d(double dx) {
   // dx^2
   double dx2 = dx * dx;
   // c0 = 1 + dx / 2
@@ -87,7 +87,7 @@ LIBC_INLINE double poly_approx_d(double dx) {
 // Return exp(dx) ~ 1 + dx + dx^2 / 2 + ... + dx^6 / 720
 // For |dx| < 2^-13 + 2^-30:
 //   | output - exp(dx) | < 2^-101
-LIBC_INLINE DoubleDouble poly_approx_dd(const DoubleDouble &dx) {
+LIBC_INLINE LIBC_CONSTEXPR DoubleDouble poly_approx_dd(const DoubleDouble &dx) {
   // Taylor polynomial.
   constexpr DoubleDouble COEFFS[] = {
       {0, 0x1p0},                                      // 1
@@ -108,7 +108,7 @@ LIBC_INLINE DoubleDouble poly_approx_dd(const DoubleDouble &dx) {
 // Return exp(dx) ~ 1 + dx + dx^2 / 2 + ... + dx^7 / 5040
 // For |dx| < 2^-13 + 2^-30:
 //   | output - exp(dx) | < 2^-126.
-LIBC_INLINE Float128 poly_approx_f128(const Float128 &dx) {
+LIBC_INLINE LIBC_CONSTEXPR Float128 poly_approx_f128(const Float128 &dx) {
   constexpr Float128 COEFFS_128[]{
       {Sign::POS, -127, 0x80000000'00000000'00000000'00000000_u128}, // 1.0
       {Sign::POS, -127, 0x80000000'00000000'00000000'00000000_u128}, // 1.0
@@ -129,7 +129,8 @@ LIBC_INLINE Float128 poly_approx_f128(const Float128 &dx) {
 // Compute exp(x) using 128-bit precision.
 // TODO(lntue): investigate triple-double precision implementation for this
 // step.
-LIBC_INLINE Float128 exp_f128(double x, double kd, int idx1, int idx2) {
+LIBC_INLINE LIBC_CONSTEXPR Float128 exp_f128(double x, double kd, int idx1,
+                                             int idx2) {
   // Recalculate dx:
 
   double t1 = fputil::multiply_add(kd, MLOG_2_EXP2_M12_HI, x); // exact
@@ -162,8 +163,8 @@ LIBC_INLINE Float128 exp_f128(double x, double kd, int idx1, int idx2) {
 }
 
 // Compute exp(x) with double-double precision.
-LIBC_INLINE DoubleDouble exp_double_double(double x, double kd,
-                                           const DoubleDouble &exp_mid) {
+LIBC_INLINE LIBC_CONSTEXPR DoubleDouble
+exp_double_double(double x, double kd, const DoubleDouble &exp_mid) {
   // Recalculate dx:
   //   dx = x - k * 2^-12 * log(2)
   double t1 = fputil::multiply_add(kd, MLOG_2_EXP2_M12_HI, x); // exact
@@ -186,7 +187,7 @@ LIBC_INLINE DoubleDouble exp_double_double(double x, double kd,
 
 // Check for exceptional cases when
 // |x| <= 2^-53 or x < log(2^-1075) or x >= 0x1.6232bdd7abcd3p+9
-LIBC_INLINE double set_exceptional(double x) {
+LIBC_INLINE constexpr double set_exceptional(double x) {
   using FPBits = typename fputil::FPBits<double>;
   FPBits xbits(x);
 
@@ -234,7 +235,7 @@ LIBC_INLINE double set_exceptional(double x) {
 
 } // namespace exp_internal
 
-LIBC_INLINE double exp(double x) {
+LIBC_INLINE LIBC_CONSTEXPR double exp(double x) {
   using namespace exp_internal;
   using FPBits = typename fputil::FPBits<double>;
   FPBits xbits(x);
diff --git a/libc/src/__support/math/exp10f16_utils.h b/libc/src/__support/math/exp10f16_utils.h
index a0fca6399a78f..16a2eb56c49d1 100644
--- a/libc/src/__support/math/exp10f16_utils.h
+++ b/libc/src/__support/math/exp10f16_utils.h
@@ -19,7 +19,7 @@
 
 namespace LIBC_NAMESPACE_DECL {
 
-LIBC_INLINE ExpRangeReduction exp10_range_reduction(float16 x) {
+LIBC_INLINE LIBC_CONSTEXPR ExpRangeReduction exp10_range_reduction(float16 x) {
   // For -8 < x < 5, to compute 10^x, we perform the following range reduction:
   // find hi, mid, lo, such that:
   //   x = (hi + mid) * log2(10) + lo, in which
diff --git a/libc/src/__support/math/expf16_utils.h b/libc/src/__support/math/expf16_utils.h
index de7add4ecf731..861b364d3982b 100644
--- a/libc/src/__support/math/expf16_utils.h
+++ b/libc/src/__support/math/expf16_utils.h
@@ -47,7 +47,8 @@ struct ExpRangeReduction {
   float exp_lo;
 };
 
-[[maybe_unused]] LIBC_INLINE ExpRangeReduction exp_range_reduction(float16 x) {
+[[maybe_unused]] LIBC_INLINE LIBC_CONSTEXPR ExpRangeReduction
+exp_range_reduction(float16 x) {
   // For -18 < x < 12, to compute exp(x), we perform the following range
   // reduction: find hi, mid, lo, such that:
   //   x = hi + mid + lo, in which
diff --git a/libc/src/__support/math/expxf16_utils.h b/libc/src/__support/math/expxf16_utils.h
index 0375eaf179b9f..43e2ffd20da4b 100644
--- a/libc/src/__support/math/expxf16_utils.h
+++ b/libc/src/__support/math/expxf16_utils.h
@@ -25,7 +25,7 @@ namespace math {
 
 namespace expxf16_internal {
 
-LIBC_INLINE ExpRangeReduction exp2_range_reduction(float16 x) {
+LIBC_INLINE LIBC_CONSTEXPR ExpRangeReduction exp2_range_reduction(float16 x) {
   // For -25 < x < 16, to compute 2^x, we perform the following range reduction:
   // find hi, mid, lo, such that:
   //   x = hi + mid + lo, in which
diff --git a/libc/src/__support/math/f16div.h b/libc/src/__support/math/f16div.h
index f53759330b867..480eb956cc047 100644
--- a/libc/src/__support/math/f16div.h
+++ b/libc/src/__support/math/f16div.h
@@ -20,7 +20,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE float16 f16div(double x, double y) {
+LIBC_INLINE constexpr float16 f16div(double x, double y) {
   return fputil::generic::div<float16>(x, y);
 }
 
diff --git a/libc/src/__support/math/f16divf.h b/libc/src/__support/math/f16divf.h
index 488a3fb191b87..06a68460fc49b 100644
--- a/libc/src/__support/math/f16divf.h
+++ b/libc/src/__support/math/f16divf.h
@@ -20,7 +20,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE float16 f16divf(float x, float y) {
+LIBC_INLINE constexpr float16 f16divf(float x, float y) {
   return fputil::generic::div<float16>(x, y);
 }
 
diff --git a/libc/src/__support/math/f16divf128.h b/libc/src/__support/math/f16divf128.h
index e0a93f60bfece..d4d9cd018901f 100644
--- a/libc/src/__support/math/f16divf128.h
+++ b/libc/src/__support/math/f16divf128.h
@@ -22,7 +22,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE float16 f16divf128(float128 x, float128 y) {
+LIBC_INLINE constexpr float16 f16divf128(float128 x, float128 y) {
   return fputil::generic::div<float16>(x, y);
 }
 
diff --git a/libc/src/__support/math/f16divl.h b/libc/src/__support/math/f16divl.h
index 6d8f63605824b..84f8d42346fd7 100644
--- a/libc/src/__support/math/f16divl.h
+++ b/libc/src/__support/math/f16divl.h
@@ -20,7 +20,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE float16 f16divl(long double x, long double y) {
+LIBC_INLINE LIBC_CONSTEXPR float16 f16divl(long double x, long double y) {
   return fputil::generic::div<float16>(x, y);
 }
 
diff --git a/libc/src/__support/math/f16fma.h b/libc/src/__support/math/f16fma.h
index 2fc8e657b9efe..8f163d1d0bae2 100644
--- a/libc/src/__support/math/f16fma.h
+++ b/libc/src/__support/math/f16fma.h
@@ -20,7 +20,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE float16 f16fma(double x, double y, double z) {
+LIBC_INLINE LIBC_CONSTEXPR float16 f16fma(double x, double y, double z) {
   return fputil::fma<float16>(x, y, z);
 }
 
diff --git a/libc/src/__support/math/f16fmaf.h b/libc/src/__support/math/f16fmaf.h
index 92f94a9721e7d..420589bc89155 100644
--- a/libc/src/__support/math/f16fmaf.h
+++ b/libc/src/__support/math/f16fmaf.h
@@ -20,7 +20,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE float16 f16fmaf(float x, float y, float z) {
+LIBC_INLINE LIBC_CONSTEXPR float16 f16fmaf(float x, float y, float z) {
   return fputil::fma<float16>(x, y, z);
 }
 
diff --git a/libc/src/__support/math/f16fmaf128.h b/libc/src/__support/math/f16fmaf128.h
index a8ba4bce9eb30..980c91489a796 100644
--- a/libc/src/__support/math/f16fmaf128.h
+++ b/libc/src/__support/math/f16fmaf128.h
@@ -23,7 +23,8 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE float16 f16fmaf128(float128 x, float128 y, float128 z) {
+LIBC_INLINE LIBC_CONSTEXPR float16 f16fmaf128(float128 x, float128 y,
+                                              float128 z) {
   return fputil::fma<float16>(x, y, z);
 }
 
diff --git a/libc/src/__support/math/f16fmal.h b/libc/src/__support/math/f16fmal.h
index 72fd6950fab49..8e24c48e553cf 100644
--- a/libc/src/__support/math/f16fmal.h
+++ b/libc/src/__support/math/f16fmal.h
@@ -20,7 +20,8 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE float16 f16fmal(long double x, long double y, long double z) {
+LIBC_INLINE LIBC_CONSTEXPR float16 f16fmal(long double x, long double y,
+                                           long double z) {
   return fputil::fma<float16>(x, y, z);
 }
 
diff --git a/libc/src/__support/math/f16mul.h b/libc/src/__support/math/f16mul.h
index 7ae906b8af279..5c4f3d0ba4c8b 100644
--- a/libc/src/__support/math/f16mul.h
+++ b/libc/src/__support/math/f16mul.h
@@ -20,7 +20,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE float16 f16mul(double x, double y) {
+LIBC_INLINE constexpr float16 f16mul(double x, double y) {
   return fputil::generic::mul<float16>(x, y);
 }
 
diff --git a/libc/src/__support/math/f16mulf.h b/libc/src/__support/math/f16mulf.h
index 9a432d3fae4f2..e912764bdabdb 100644
--- a/libc/src/__support/math/f16mulf.h
+++ b/libc/src/__support/math/f16mulf.h
@@ -20,7 +20,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE float16 f16mulf(float x, float y) {
+LIBC_INLINE constexpr float16 f16mulf(float x, float y) {
   return fputil::generic::mul<float16>(x, y);
 }
 
diff --git a/libc/src/__support/math/f16mulf128.h b/libc/src/__support/math/f16mulf128.h
index 54a90957269a7..398fdd6066f18 100644
--- a/libc/src/__support/math/f16mulf128.h
+++ b/libc/src/__support/math/f16mulf128.h
@@ -22,7 +22,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE float16 f16mulf128(float128 x, float128 y) {
+LIBC_INLINE constexpr float16 f16mulf128(float128 x, float128 y) {
   return fputil::generic::mul<float16>(x, y);
 }
 
diff --git a/libc/src/__support/math/f16mull.h b/libc/src/__support/math/f16mull.h
index 5fee45ad01124..2c0546bd87c5b 100644
--- a/libc/src/__support/math/f16mull.h
+++ b/libc/src/__support/math/f16mull.h
@@ -20,7 +20,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE float16 f16mull(long double x, long double y) {
+LIBC_INLINE constexpr float16 f16mull(long double x, long double y) {
   return fputil::generic::mul<float16>(x, y);
 }
 
diff --git a/libc/src/__support/math/f16sqrtf128.h b/libc/src/__support/math/f16sqrtf128.h
index 3ef74136cba94..0471b1f6b1455 100644
--- a/libc/src/__support/math/f16sqrtf128.h
+++ b/libc/src/__support/math/f16sqrtf128.h
@@ -22,7 +22,9 @@
 namespace LIBC_NAMESPACE_DECL {
 namespace math {
 
-LIBC_INLINE float16 f16sqrtf128(float128 x) { return fputil::sqrt<float16>(x); }
+LIBC_INLINE constexpr float16 f16sqrtf128(float128 x) {
+  return fputil::sqrt<float16>(x);
+}
 
 } // namespace math
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/__support/math/f16sub.h b/libc/src/__support/math/f16sub.h
index 3280fb08e3103..4ec8bdc9c18e4 100644
--- a/libc/src/__support/math/f16sub.h
+++ b/libc/src/__support/math/f16sub.h
@@ -20,7 +20,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE float16 f16sub(double x, double y) {
+LIBC_INLINE constexpr float16 f16sub(double x, double y) {
   return fputil::generic::sub<float16>(x, y);
 }
 
diff --git a/libc/src/__support/math/f16subf.h b/libc/src/__support/math/f16subf.h
index 1e19e90d18a6b..63a401577ee89 100644
--- a/libc/src/__support/math/f16subf.h
+++ b/libc/src/__support/math/f16subf.h
@@ -20,7 +20,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE float16 f16subf(float x, float y) {
+LIBC_INLINE constexpr float16 f16subf(float x, float y) {
   return fputil::generic::sub<float16>(x, y);
 }
 
diff --git a/libc/src/__support/math/f16subf128.h b/libc/src/__support/math/f16subf128.h
index a85b30fba53fa..0e2da72821a9c 100644
--- a/libc/src/__support/math/f16subf128.h
+++ b/libc/src/__support/math/f16subf128.h
@@ -22,7 +22,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE float16 f16subf128(float128 x, float128 y) {
+LIBC_INLINE constexpr float16 f16subf128(float128 x, float128 y) {
   return fputil::generic::sub<float16>(x, y);
 }
 
diff --git a/libc/src/__support/math/f16subl.h b/libc/src/__support/math/f16subl.h
index 4515517f60ca2..caeccb054be5c 100644
--- a/libc/src/__support/math/f16subl.h
+++ b/libc/src/__support/math/f16subl.h
@@ -20,7 +20,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE float16 f16subl(long double x, long double y) {
+LIBC_INLINE constexpr float16 f16subl(long double x, long double y) {
   return fputil::generic::sub<float16>(x, y);
 }
 
diff --git a/libc/src/__support/math/ffma.h b/libc/src/__support/math/ffma.h
index 64431e8bec407..bc89094b16e71 100644
--- a/libc/src/__support/math/ffma.h
+++ b/libc/src/__support/math/ffma.h
@@ -16,7 +16,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE float ffma(double x, double y, double z) {
+LIBC_INLINE LIBC_CONSTEXPR float ffma(double x, double y, double z) {
   return fputil::fma<float>(x, y, z);
 }
 
diff --git a/libc/src/__support/math/ffmaf128.h b/libc/src/__support/math/ffmaf128.h
index c4b5a58e145fa..7361efa0655f9 100644
--- a/libc/src/__support/math/ffmaf128.h
+++ b/libc/src/__support/math/ffmaf128.h
@@ -21,7 +21,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE float ffmaf128(float128 x, float128 y, float128 z) {
+LIBC_INLINE constexpr float ffmaf128(float128 x, float128 y, float128 z) {
   return fputil::fma<float>(x, y, z);
 }
 
diff --git a/libc/src/__support/math/ffmal.h b/libc/src/__support/math/ffmal.h
index b03c45ea25cf2..029a499ecda1b 100644
--- a/libc/src/__support/math/ffmal.h
+++ b/libc/src/__support/math/ffmal.h
@@ -17,7 +17,8 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE float ffmal(long double x, long double y, long double z) {
+LIBC_INLINE LIBC_CONSTEXPR float ffmal(long double x, long double y,
+                                       long double z) {
   return fputil::fma<float>(x, y, z);
 }
 
diff --git a/libc/src/__support/math/fma.h b/libc/src/__support/math/fma.h
index 723ff9fecd9f0..4856bb2a5224e 100644
--- a/libc/src/__support/math/fma.h
+++ b/libc/src/__support/math/fma.h
@@ -16,7 +16,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE double fma(double x, double y, double z) {
+LIBC_INLINE LIBC_CONSTEXPR double fma(double x, double y, double z) {
   return fputil::fma<double>(x, y, z);
 }
 
diff --git a/libc/src/__support/math/fmabf16.h b/libc/src/__support/math/fmabf16.h
index 41a99df2d952b..d71c68ffb79f4 100644
--- a/libc/src/__support/math/fmabf16.h
+++ b/libc/src/__support/math/fmabf16.h
@@ -17,7 +17,7 @@
 namespace LIBC_NAMESPACE_DECL {
 namespace math {
 
-LIBC_INLINE bfloat16 fmabf16(bfloat16 x, bfloat16 y, bfloat16 z) {
+LIBC_INLINE constexpr bfloat16 fmabf16(bfloat16 x, bfloat16 y, bfloat16 z) {
   return fputil::fma<bfloat16>(x, y, z);
 }
 
diff --git a/libc/src/__support/math/fmaf.h b/libc/src/__support/math/fmaf.h
index 0437bb0ff44d6..e8409d1157827 100644
--- a/libc/src/__support/math/fmaf.h
+++ b/libc/src/__support/math/fmaf.h
@@ -16,7 +16,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE float fmaf(float x, float y, float z) {
+LIBC_INLINE LIBC_CONSTEXPR float fmaf(float x, float y, float z) {
   return fputil::fma<float>(x, y, z);
 }
 
diff --git a/libc/src/__support/math/fmaf16.h b/libc/src/__support/math/fmaf16.h
index 2e061a97a2bd2..46aabe2694d65 100644
--- a/libc/src/__support/math/fmaf16.h
+++ b/libc/src/__support/math/fmaf16.h
@@ -20,7 +20,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE float16 fmaf16(float16 x, float16 y, float16 z) {
+LIBC_INLINE constexpr float16 fmaf16(float16 x, float16 y, float16 z) {
   return fputil::fma<float16>(x, y, z);
 }
 
diff --git a/libc/src/__support/math/fmaxf.h b/libc/src/__support/math/fmaxf.h
index 862d9bf1bd062..fe6effb9cf5ee 100644
--- a/libc/src/__support/math/fmaxf.h
+++ b/libc/src/__support/math/fmaxf.h
@@ -15,7 +15,7 @@
 namespace LIBC_NAMESPACE_DECL {
 namespace math {
 
-LIBC_INLINE float constexpr fmaxf(float x, float y) {
+LIBC_INLINE constexpr float fmaxf(float x, float y) {
   return fputil::fmax(x, y);
 }
 
diff --git a/libc/src/__support/math/hypot.h b/libc/src/__support/math/hypot.h
index 13d6e3fecff01..a4da1eecfd68f 100644
--- a/libc/src/__support/math/hypot.h
+++ b/libc/src/__support/math/hypot.h
@@ -16,7 +16,9 @@
 namespace LIBC_NAMESPACE_DECL {
 namespace math {
 
-LIBC_INLINE double hypot(double x, double y) { return fputil::hypot(x, y); }
+LIBC_INLINE constexpr double hypot(double x, double y) {
+  return fputil::hypot(x, y);
+}
 
 } // namespace math
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/__support/math/hypotbf16.h b/libc/src/__support/math/hypotbf16.h
index e04013e4e3d68..ef870a9d36073 100644
--- a/libc/src/__support/math/hypotbf16.h
+++ b/libc/src/__support/math/hypotbf16.h
@@ -18,7 +18,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE bfloat16 hypotbf16(bfloat16 x, bfloat16 y) {
+LIBC_INLINE constexpr bfloat16 hypotbf16(bfloat16 x, bfloat16 y) {
   return fputil::hypot<bfloat16>(x, y);
 }
 
diff --git a/libc/src/__support/math/hypotf.h b/libc/src/__support/math/hypotf.h
index 5d877db190ace..a8a4070a656d4 100644
--- a/libc/src/__support/math/hypotf.h
+++ b/libc/src/__support/math/hypotf.h
@@ -22,7 +22,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE float hypotf(float x, float y) {
+LIBC_INLINE LIBC_CONSTEXPR float hypotf(float x, float y) {
   using DoubleBits = fputil::FPBits<double>;
   using FPBits = fputil::FPBits<float>;
   using fputil::DoubleDouble;
@@ -51,7 +51,7 @@ LIBC_INLINE float hypotf(float x, float y) {
   // x^2 and y^2 are exact in double precision.
   double x_sq = xd * xd;
 
-  double sum_sq;
+  double sum_sq{};
 #ifdef LIBC_TARGET_CPU_HAS_FMA_DOUBLE
   sum_sq = fputil::multiply_add(yd, yd, x_sq);
 #else
diff --git a/libc/src/__support/math/hypotf16.h b/libc/src/__support/math/hypotf16.h
index 07e8a0566b8ec..a647f170cc380 100644
--- a/libc/src/__support/math/hypotf16.h
+++ b/libc/src/__support/math/hypotf16.h
@@ -24,7 +24,7 @@ namespace math {
 
 // For targets where conversion from float to float16 has to be
 // emulated, fputil::hypot<float16> is faster
-LIBC_INLINE float16 hypotf16(float16 x, float16 y) {
+LIBC_INLINE LIBC_CONSTEXPR float16 hypotf16(float16 x, float16 y) {
   using FloatBits = fputil::FPBits<float>;
   using FPBits = fputil::FPBits<float16>;
 
diff --git a/libc/src/__support/math/log10f16.h b/libc/src/__support/math/log10f16.h
index 0c0b9a98086d9..8c8b8f78fdf73 100644
--- a/libc/src/__support/math/log10f16.h
+++ b/libc/src/__support/math/log10f16.h
@@ -84,7 +84,7 @@ LIBC_INLINE_VAR constexpr fputil::ExceptValues<float16, N_LOG10F16_EXCEPTS>
 #endif // !LIBC_MATH_HAS_SKIP_ACCURATE_PASS
 } // namespace log10f16_internal
 
-LIBC_INLINE float16 log10f16(float16 x) {
+LIBC_INLINE LIBC_CONSTEXPR float16 log10f16(float16 x) {
   using namespace math::expxf16_internal;
   using FPBits = fputil::FPBits<float16>;
   FPBits x_bits(x);
diff --git a/libc/src/__support/math/log10p1f16.h b/libc/src/__support/math/log10p1f16.h
index 54533c994df81..5b656266493da 100644
--- a/libc/src/__support/math/log10p1f16.h
+++ b/libc/src/__support/math/log10p1f16.h
@@ -32,7 +32,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE float16 log10p1f16(float16 x) {
+LIBC_INLINE LIBC_CONSTEXPR float16 log10p1f16(float16 x) {
   using namespace math::expxf16_internal;
   using FPBits = fputil::FPBits<float16>;
   FPBits x_bits(x);
diff --git a/libc/src/__support/math/log1pf.h b/libc/src/__support/math/log1pf.h
index 49244f38f8905..ab62ae20dbb24 100644
--- a/libc/src/__support/math/log1pf.h
+++ b/libc/src/__support/math/log1pf.h
@@ -37,7 +37,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE float log1pf(float x) {
+LIBC_INLINE LIBC_CONSTEXPR float log1pf(float x) {
   using FPBits = typename fputil::FPBits<float>;
   FPBits xbits(x);
   uint32_t x_u = xbits.uintval();
diff --git a/libc/src/__support/math/log2f16.h b/libc/src/__support/math/log2f16.h
index df9402f2c8175..0f8b5fb6c43ee 100644
--- a/libc/src/__support/math/log2f16.h
+++ b/libc/src/__support/math/log2f16.h
@@ -72,7 +72,7 @@ LIBC_INLINE_VAR constexpr fputil::ExceptValues<float16, N_LOG2F16_EXCEPTS>
 
 } // namespace log2f16_internal
 
-LIBC_INLINE float16 log2f16(float16 x) {
+LIBC_INLINE LIBC_CONSTEXPR float16 log2f16(float16 x) {
   using namespace math::expxf16_internal;
   using FPBits = fputil::FPBits<float16>;
   FPBits x_bits(x);
diff --git a/libc/src/__support/math/log2p1f16.h b/libc/src/__support/math/log2p1f16.h
index 4fe9de42d71b3..595c56db589d9 100644
--- a/libc/src/__support/math/log2p1f16.h
+++ b/libc/src/__support/math/log2p1f16.h
@@ -31,7 +31,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE float16 log2p1f16(float16 x) {
+LIBC_INLINE LIBC_CONSTEXPR float16 log2p1f16(float16 x) {
   using namespace math::expxf16_internal;
   using FPBits = fputil::FPBits<float16>;
   FPBits x_bits(x);
diff --git a/libc/src/__support/math/logf16.h b/libc/src/__support/math/logf16.h
index 77682e6082e0b..f42c0b17293fa 100644
--- a/libc/src/__support/math/logf16.h
+++ b/libc/src/__support/math/logf16.h
@@ -78,7 +78,7 @@ LIBC_INLINE_VAR constexpr fputil::ExceptValues<float16, N_LOGF16_EXCEPTS>
 
 } // namespace logf16_internal
 
-LIBC_INLINE float16 logf16(float16 x) {
+LIBC_INLINE LIBC_CONSTEXPR float16 logf16(float16 x) {
   using namespace math::expxf16_internal;
   using namespace math::logf16_internal;
   using FPBits = fputil::FPBits<float16>;
diff --git a/libc/src/__support/math/nextafter.h b/libc/src/__support/math/nextafter.h
index 625d5a7c68f61..80abd374f009a 100644
--- a/libc/src/__support/math/nextafter.h
+++ b/libc/src/__support/math/nextafter.h
@@ -16,7 +16,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE constexpr double nextafter(double x, double y) {
+LIBC_INLINE LIBC_CONSTEXPR double nextafter(double x, double y) {
   return fputil::nextafter(x, y);
 }
 
diff --git a/libc/src/__support/math/nextafterbf16.h b/libc/src/__support/math/nextafterbf16.h
index b13a194d56fd8..b9cf7cad008c8 100644
--- a/libc/src/__support/math/nextafterbf16.h
+++ b/libc/src/__support/math/nextafterbf16.h
@@ -17,7 +17,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE constexpr bfloat16 nextafterbf16(bfloat16 x, bfloat16 y) {
+LIBC_INLINE LIBC_CONSTEXPR bfloat16 nextafterbf16(bfloat16 x, bfloat16 y) {
   return fputil::nextafter(x, y);
 }
 
diff --git a/libc/src/__support/math/nextafterf.h b/libc/src/__support/math/nextafterf.h
index c6baa8a2012ab..eaaeff84c960c 100644
--- a/libc/src/__support/math/nextafterf.h
+++ b/libc/src/__support/math/nextafterf.h
@@ -16,7 +16,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE constexpr float nextafterf(float x, float y) {
+LIBC_INLINE LIBC_CONSTEXPR float nextafterf(float x, float y) {
   return fputil::nextafter(x, y);
 }
 
diff --git a/libc/src/__support/math/nextafterf128.h b/libc/src/__support/math/nextafterf128.h
index 2f15bd41c0476..686c6980e63ed 100644
--- a/libc/src/__support/math/nextafterf128.h
+++ b/libc/src/__support/math/nextafterf128.h
@@ -20,7 +20,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE constexpr float128 nextafterf128(float128 x, float128 y) {
+LIBC_INLINE LIBC_CONSTEXPR float128 nextafterf128(float128 x, float128 y) {
   return fputil::nextafter(x, y);
 }
 
diff --git a/libc/src/__support/math/nextafterf16.h b/libc/src/__support/math/nextafterf16.h
index edb91c3e3cbdb..bd7f9335208b3 100644
--- a/libc/src/__support/math/nextafterf16.h
+++ b/libc/src/__support/math/nextafterf16.h
@@ -20,7 +20,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE constexpr float16 nextafterf16(float16 x, float16 y) {
+LIBC_INLINE LIBC_CONSTEXPR float16 nextafterf16(float16 x, float16 y) {
   return fputil::nextafter(x, y);
 }
 
diff --git a/libc/src/__support/math/nextafterl.h b/libc/src/__support/math/nextafterl.h
index a173ccfaa4c73..40a15a63bbcca 100644
--- a/libc/src/__support/math/nextafterl.h
+++ b/libc/src/__support/math/nextafterl.h
@@ -16,7 +16,8 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE constexpr long double nextafterl(long double x, long double y) {
+LIBC_INLINE LIBC_CONSTEXPR long double nextafterl(long double x,
+                                                  long double y) {
   return fputil::nextafter(x, y);
 }
 
diff --git a/libc/src/__support/math/nexttoward.h b/libc/src/__support/math/nexttoward.h
index 7f9ba9df3a816..1518c8942a745 100644
--- a/libc/src/__support/math/nexttoward.h
+++ b/libc/src/__support/math/nexttoward.h
@@ -16,7 +16,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE double nexttoward(double x, long double y) {
+LIBC_INLINE LIBC_CONSTEXPR double nexttoward(double x, long double y) {
   // We can reuse the nextafter implementation because the internal nextafter is
   // templated on the types of the arguments.
   return fputil::nextafter(x, y);
diff --git a/libc/src/__support/math/nexttowardbf16.h b/libc/src/__support/math/nexttowardbf16.h
index 3d0d278f6801f..8a864cce7e61b 100644
--- a/libc/src/__support/math/nexttowardbf16.h
+++ b/libc/src/__support/math/nexttowardbf16.h
@@ -17,7 +17,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE bfloat16 nexttowardbf16(bfloat16 x, long double y) {
+LIBC_INLINE LIBC_CONSTEXPR bfloat16 nexttowardbf16(bfloat16 x, long double y) {
   // nextafter<T, U> where T != U is nexttoward
   return fputil::nextafter(x, y);
 }
diff --git a/libc/src/__support/math/nexttowardf.h b/libc/src/__support/math/nexttowardf.h
index 575b50744cd2f..6ac1e98d24749 100644
--- a/libc/src/__support/math/nexttowardf.h
+++ b/libc/src/__support/math/nexttowardf.h
@@ -16,7 +16,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE float nexttowardf(float x, long double y) {
+LIBC_INLINE LIBC_CONSTEXPR float nexttowardf(float x, long double y) {
   // We can reuse the nextafter implementation because the internal nextafter is
   // templated on the types of the arguments.
   return fputil::nextafter(x, y);
diff --git a/libc/src/__support/math/nexttowardf16.h b/libc/src/__support/math/nexttowardf16.h
index 9e5b3ef049b2d..6fb3c36ec4381 100644
--- a/libc/src/__support/math/nexttowardf16.h
+++ b/libc/src/__support/math/nexttowardf16.h
@@ -17,10 +17,9 @@
 #include "src/__support/macros/config.h"
 
 namespace LIBC_NAMESPACE_DECL {
-
 namespace math {
 
-LIBC_INLINE float16 nexttowardf16(float16 x, long double y) {
+LIBC_INLINE LIBC_CONSTEXPR float16 nexttowardf16(float16 x, long double y) {
   // We can reuse the nextafter implementation because the internal nextafter is
   // templated on the types of the arguments.
   return fputil::nextafter(x, y);
diff --git a/libc/src/__support/math/nexttowardl.h b/libc/src/__support/math/nexttowardl.h
index b1a7a66f69886..de8c6543bfaf4 100644
--- a/libc/src/__support/math/nexttowardl.h
+++ b/libc/src/__support/math/nexttowardl.h
@@ -16,7 +16,8 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE long double nexttowardl(long double x, long double y) {
+LIBC_INLINE LIBC_CONSTEXPR long double nexttowardl(long double x,
+                                                   long double y) {
   // We can reuse the nextafter implementation because the internal nextafter is
   // templated on the types of the arguments.
   return fputil::nextafter(x, y);
diff --git a/libc/src/__support/math/range_reduction.h b/libc/src/__support/math/range_reduction.h
index 93ec9846e5f1b..8a18a2c10c883 100644
--- a/libc/src/__support/math/range_reduction.h
+++ b/libc/src/__support/math/range_reduction.h
@@ -44,7 +44,7 @@ LIBC_INLINE_VAR constexpr int THIRTYTWO_OVER_PI_28_LSB_EXP[N_ENTRIES] = {
 
 // Return k and y, where
 //   k = round(x * 16 / pi) and y = (x * 16 / pi) - k.
-LIBC_INLINE int64_t small_range_reduction(double x, double &y) {
+LIBC_INLINE LIBC_CONSTEXPR int64_t small_range_reduction(double x, double &y) {
   double prod = x * THIRTYTWO_OVER_PI_28[0];
   double kd = fputil::nearest_integer(prod);
   y = prod - kd;
@@ -59,7 +59,8 @@ LIBC_INLINE int64_t small_range_reduction(double x, double &y) {
 // contributing to the lowest 6 binary digits (k & 63).  If the least
 // significant bit of x * the least significant bit of THIRTYTWO_OVER_PI_28[i]
 // >= 64, we can completely ignore THIRTYTWO_OVER_PI_28[i].
-LIBC_INLINE int64_t large_range_reduction(double x, int x_exp, double &y) {
+LIBC_INLINE LIBC_CONSTEXPR int64_t large_range_reduction(double x, int x_exp,
+                                                         double &y) {
   int idx = 0;
   y = 0;
   int x_lsb_exp_m4 = x_exp - fputil::FPBits<float>::FRACTION_LEN;
diff --git a/libc/src/__support/math/range_reduction_double_common.h b/libc/src/__support/math/range_reduction_double_common.h
index 5888ca5f833ef..05ad23ef551e5 100644
--- a/libc/src/__support/math/range_reduction_double_common.h
+++ b/libc/src/__support/math/range_reduction_double_common.h
@@ -253,7 +253,7 @@ struct LargeRangeReduction {
 
   // To be implemented in range_reduction_double_fma.h and
   // range_reduction_double_nofma.h.
-  unsigned fast(double x, DoubleDouble &u);
+  LIBC_CONSTEXPR unsigned fast(double x, DoubleDouble &u);
 
 #ifndef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
   LIBC_INLINE Float128 accurate() const {
diff --git a/libc/src/__support/math/range_reduction_double_fma.h b/libc/src/__support/math/range_reduction_double_fma.h
index b03d7f08713a3..68957355c6d6d 100644
--- a/libc/src/__support/math/range_reduction_double_fma.h
+++ b/libc/src/__support/math/range_reduction_double_fma.h
@@ -24,7 +24,8 @@ namespace range_reduction_double_internal {
 
 using LIBC_NAMESPACE::fputil::DoubleDouble;
 
-LIBC_INLINE unsigned LargeRangeReduction::fast(double x, DoubleDouble &u) {
+LIBC_INLINE LIBC_CONSTEXPR unsigned LargeRangeReduction::fast(double x,
+                                                              DoubleDouble &u) {
   using FPBits = typename fputil::FPBits<double>;
   FPBits xbits(x);
 
diff --git a/libc/src/__support/math/range_reduction_double_nofma.h b/libc/src/__support/math/range_reduction_double_nofma.h
index d3ad74b6ffb7d..701c7f1416679 100644
--- a/libc/src/__support/math/range_reduction_double_nofma.h
+++ b/libc/src/__support/math/range_reduction_double_nofma.h
@@ -26,7 +26,8 @@ namespace range_reduction_double_internal {
 
 using fputil::DoubleDouble;
 
-LIBC_INLINE unsigned LargeRangeReduction::fast(double x, DoubleDouble &u) {
+LIBC_INLINE LIBC_CONSTEXPR unsigned LargeRangeReduction::fast(double x,
+                                                              DoubleDouble &u) {
   using FPBits = typename fputil::FPBits<double>;
   FPBits xbits(x);
 
diff --git a/libc/src/__support/math/range_reduction_fma.h b/libc/src/__support/math/range_reduction_fma.h
index fe6d94946af7e..f01c27fec3bbe 100644
--- a/libc/src/__support/math/range_reduction_fma.h
+++ b/libc/src/__support/math/range_reduction_fma.h
@@ -33,7 +33,7 @@ LIBC_INLINE_VAR constexpr double THIRTYTWO_OVER_PI[5] = {
 
 // Return k and y, where
 //   k = round(x * 32 / pi) and y = (x * 32 / pi) - k.
-LIBC_INLINE int64_t small_range_reduction(double x, double &y) {
+LIBC_INLINE LIBC_CONSTEXPR int64_t small_range_reduction(double x, double &y) {
   double kd = fputil::nearest_integer(x * THIRTYTWO_OVER_PI[0]);
   y = fputil::fma<double>(x, THIRTYTWO_OVER_PI[0], -kd);
   y = fputil::fma<double>(x, THIRTYTWO_OVER_PI[1], y);
@@ -43,7 +43,8 @@ LIBC_INLINE int64_t small_range_reduction(double x, double &y) {
 // Return k and y, where
 //   k = round(x * 32 / pi) and y = (x * 32 / pi) - k.
 // This is used for sinf, cosf, sincosf.
-LIBC_INLINE int64_t large_range_reduction(double x, int x_exp, double &y) {
+LIBC_INLINE LIBC_CONSTEXPR int64_t large_range_reduction(double x, int x_exp,
+                                                         double &y) {
   // 2^45 <= |x| < 2^99
   if (x_exp < 99) {
     // - When x < 2^99, the full exact product of x * THIRTYTWO_OVER_PI[0]
diff --git a/libc/src/__support/math/setpayloadsig.h b/libc/src/__support/math/setpayloadsig.h
index 2c19ceadfae36..460ff8ab37d7a 100644
--- a/libc/src/__support/math/setpayloadsig.h
+++ b/libc/src/__support/math/setpayloadsig.h
@@ -16,7 +16,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE int setpayloadsig(double *res, double pl) {
+LIBC_INLINE constexpr int setpayloadsig(double *res, double pl) {
   return static_cast<int>(fputil::setpayload</*IsSignaling=*/true>(*res, pl));
 }
 
diff --git a/libc/src/__support/math/setpayloadsigbf16.h b/libc/src/__support/math/setpayloadsigbf16.h
index 58bf078e7e328..21f0e98792075 100644
--- a/libc/src/__support/math/setpayloadsigbf16.h
+++ b/libc/src/__support/math/setpayloadsigbf16.h
@@ -17,7 +17,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE int setpayloadsigbf16(bfloat16 *res, bfloat16 pl) {
+LIBC_INLINE constexpr int setpayloadsigbf16(bfloat16 *res, bfloat16 pl) {
   return static_cast<int>(fputil::setpayload</*IsSignaling=*/true>(*res, pl));
 }
 
diff --git a/libc/src/__support/math/setpayloadsigf.h b/libc/src/__support/math/setpayloadsigf.h
index 95a0540eb4444..7d8b57255ff3a 100644
--- a/libc/src/__support/math/setpayloadsigf.h
+++ b/libc/src/__support/math/setpayloadsigf.h
@@ -16,7 +16,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE int setpayloadsigf(float *res, float pl) {
+LIBC_INLINE constexpr int setpayloadsigf(float *res, float pl) {
   return static_cast<int>(fputil::setpayload</*IsSignaling=*/true>(*res, pl));
 }
 
diff --git a/libc/src/__support/math/setpayloadsigf128.h b/libc/src/__support/math/setpayloadsigf128.h
index fa49c1d58653a..87233415612ef 100644
--- a/libc/src/__support/math/setpayloadsigf128.h
+++ b/libc/src/__support/math/setpayloadsigf128.h
@@ -20,7 +20,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE int setpayloadsigf128(float128 *res, float128 pl) {
+LIBC_INLINE constexpr int setpayloadsigf128(float128 *res, float128 pl) {
   return static_cast<int>(fputil::setpayload</*IsSignaling=*/true>(*res, pl));
 }
 
diff --git a/libc/src/__support/math/setpayloadsigf16.h b/libc/src/__support/math/setpayloadsigf16.h
index e3629cfe3d00e..92443d4b091d8 100644
--- a/libc/src/__support/math/setpayloadsigf16.h
+++ b/libc/src/__support/math/setpayloadsigf16.h
@@ -20,7 +20,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE int setpayloadsigf16(float16 *res, float16 pl) {
+LIBC_INLINE constexpr int setpayloadsigf16(float16 *res, float16 pl) {
   return static_cast<int>(fputil::setpayload</*IsSignaling=*/true>(*res, pl));
 }
 
diff --git a/libc/src/__support/math/setpayloadsigl.h b/libc/src/__support/math/setpayloadsigl.h
index 9b9de4109e06f..7bbfa586b2197 100644
--- a/libc/src/__support/math/setpayloadsigl.h
+++ b/libc/src/__support/math/setpayloadsigl.h
@@ -16,7 +16,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE int setpayloadsigl(long double *res, long double pl) {
+LIBC_INLINE constexpr int setpayloadsigl(long double *res, long double pl) {
   return static_cast<int>(fputil::setpayload</*IsSignaling=*/true>(*res, pl));
 }
 
diff --git a/libc/src/__support/math/sin_integer_eval.h b/libc/src/__support/math/sin_integer_eval.h
index 5aa1f27e9d111..8a7e02d0c06dc 100644
--- a/libc/src/__support/math/sin_integer_eval.h
+++ b/libc/src/__support/math/sin_integer_eval.h
@@ -23,7 +23,7 @@ namespace math {
 
 namespace integer_only {
 
-LIBC_INLINE double sin(double x) {
+LIBC_INLINE constexpr double sin(double x) {
   using FPBits = typename fputil::FPBits<double>;
   FPBits xbits(x);
 
diff --git a/libc/src/__support/math/sincos.h b/libc/src/__support/math/sincos.h
index 11727c3bf3807..616af892cf15d 100644
--- a/libc/src/__support/math/sincos.h
+++ b/libc/src/__support/math/sincos.h
@@ -34,7 +34,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE void sincos(double x, double *sin_x, double *cos_x) {
+LIBC_INLINE LIBC_CONSTEXPR void sincos(double x, double *sin_x, double *cos_x) {
   using DoubleDouble = fputil::DoubleDouble;
   using namespace math::range_reduction_double_internal;
   using FPBits = typename fputil::FPBits<double>;
diff --git a/libc/src/__support/math/sincos_integer_utils.h b/libc/src/__support/math/sincos_integer_utils.h
index 45bbba12b0ac4..90a9f8b11e13e 100644
--- a/libc/src/__support/math/sincos_integer_utils.h
+++ b/libc/src/__support/math/sincos_integer_utils.h
@@ -86,8 +86,8 @@ LIBC_INLINE_VAR constexpr Frac128 PI_OVER_2_M1({0x898c'c517'01b8'39a2,
 //   x_frac: |x - k * pi/2|
 // Return:
 //   x_frac_is_neg.
-LIBC_INLINE bool trig_range_reduction(uint64_t x_u, unsigned x_e, unsigned &k,
-                                      Frac128 &x_frac) {
+LIBC_INLINE LIBC_CONSTEXPR bool
+trig_range_reduction(uint64_t x_u, unsigned x_e, unsigned &k, Frac128 &x_frac) {
   using FPBits = typename fputil::FPBits<double>;
   bool x_frac_is_neg = false;
   // We do multiplication x * (2/pi)
@@ -221,8 +221,8 @@ LIBC_INLINE_VAR constexpr Frac128 COS_COEFF[] = {
 };
 
 // Compute sin(x) with relative errors ~ 2^-54.
-LIBC_INLINE double sin_eval(const Frac128 &x_frac, unsigned k, bool is_neg,
-                            bool x_frac_is_neg) {
+LIBC_INLINE constexpr double sin_eval(const Frac128 &x_frac, unsigned k,
+                                      bool is_neg, bool x_frac_is_neg) {
   // cos when k = 1, 3
   bool is_cos = ((k & 1) == 1);
   // flip sign when k = 2, 3
diff --git a/libc/src/__support/math/sincosf_utils.h b/libc/src/__support/math/sincosf_utils.h
index 8fbc8384f9e32..7663cd94ca4ba 100644
--- a/libc/src/__support/math/sincosf_utils.h
+++ b/libc/src/__support/math/sincosf_utils.h
@@ -46,7 +46,7 @@ using math::trigonometric_func_utils_internal::small_range_reduction;
 // Table is generated with Sollya as follow:
 // > display = hexadecimal;
 // > for k from 0 to 63 do { D(sin(k * pi/32)); };
-LIBC_INLINE_VAR const double SIN_K_PI_OVER_32[64] = {
+LIBC_INLINE_VAR constexpr double SIN_K_PI_OVER_32[64] = {
     0x0.0000000000000p+0,  0x1.917a6bc29b42cp-4,  0x1.8f8b83c69a60bp-3,
     0x1.294062ed59f06p-2,  0x1.87de2a6aea963p-2,  0x1.e2b5d3806f63bp-2,
     0x1.1c73b39ae68c8p-1,  0x1.44cf325091dd6p-1,  0x1.6a09e667f3bcdp-1,
@@ -71,9 +71,10 @@ LIBC_INLINE_VAR const double SIN_K_PI_OVER_32[64] = {
     -0x1.917a6bc29b42cp-4,
 };
 
-LIBC_INLINE void sincosf_poly_eval(int64_t k, double y, double &sin_k,
-                                   double &cos_k, double &sin_y,
-                                   double &cosm1_y) {
+LIBC_INLINE LIBC_CONSTEXPR void sincosf_poly_eval(int64_t k, double y,
+                                                  double &sin_k, double &cos_k,
+                                                  double &sin_y,
+                                                  double &cosm1_y) {
   // After range reduction, k = round(x * 32 / pi) and y = (x * 32 / pi) - k.
   // So k is an integer and -0.5 <= y <= 0.5.
   // Then sin(x) = sin((k + y)*pi/32)
@@ -99,10 +100,11 @@ LIBC_INLINE void sincosf_poly_eval(int64_t k, double y, double &sin_k,
                                    0x1.03c1f070c2e27p-18, -0x1.55cc84bd942p-30);
 }
 
-LIBC_INLINE void sincosf_eval(double xd, uint32_t x_abs, double &sin_k,
-                              double &cos_k, double &sin_y, double &cosm1_y) {
-  int64_t k;
-  double y;
+LIBC_INLINE LIBC_CONSTEXPR void sincosf_eval(double xd, uint32_t x_abs,
+                                             double &sin_k, double &cos_k,
+                                             double &sin_y, double &cosm1_y) {
+  int64_t k{};
+  double y{};
 
   if (LIBC_LIKELY(x_abs < FAST_PASS_BOUND)) {
     k = small_range_reduction(xd, y);
diff --git a/libc/src/__support/math/sinf.h b/libc/src/__support/math/sinf.h
index c61beed749900..23b3a39920d64 100644
--- a/libc/src/__support/math/sinf.h
+++ b/libc/src/__support/math/sinf.h
@@ -29,7 +29,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE float sinf(float x) {
+LIBC_INLINE LIBC_CONSTEXPR float sinf(float x) {
   return math::sincosf_float_eval::sincosf_eval</*IS_SIN*/ true>(x);
 }
 
diff --git a/libc/src/__support/math/sinf16.h b/libc/src/__support/math/sinf16.h
index ec27c4ec61c53..14622490be69d 100644
--- a/libc/src/__support/math/sinf16.h
+++ b/libc/src/__support/math/sinf16.h
@@ -44,7 +44,7 @@ LIBC_INLINE_VAR constexpr fputil::ExceptValues<float16, N_EXCEPTS>
 
 } // namespace sinf16_internal
 
-LIBC_INLINE float16 sinf16(float16 x) {
+LIBC_INLINE LIBC_CONSTEXPR float16 sinf16(float16 x) {
   using namespace sinf16_internal;
   using namespace sincosf16_internal;
   using FPBits = fputil::FPBits<float16>;
@@ -115,7 +115,7 @@ LIBC_INLINE float16 sinf16(float16 x) {
     return x + FPBits::quiet_nan().get_val();
   }
 
-  float sin_k, cos_k, sin_y, cosm1_y;
+  float sin_k{}, cos_k{}, sin_y{}, cosm1_y{};
   sincosf16_eval(xf, sin_k, cos_k, sin_y, cosm1_y);
 
   if (LIBC_UNLIKELY(sin_y == 0 && sin_k == 0))
diff --git a/libc/src/__support/math/sinhfcoshf_utils.h b/libc/src/__support/math/sinhfcoshf_utils.h
index 5f19b81246980..4ad44d9b6b05e 100644
--- a/libc/src/__support/math/sinhfcoshf_utils.h
+++ b/libc/src/__support/math/sinhfcoshf_utils.h
@@ -55,14 +55,14 @@ namespace sinhfcoshf_internal {
 // The main point of these formulas is that the expensive part of calculating
 // the polynomials approximating lower parts of e^(x) and e^(-x) are shared
 // and only done once.
-template <bool is_sinh> LIBC_INLINE double exp_pm_eval(float x) {
+template <bool is_sinh> LIBC_INLINE LIBC_CONSTEXPR double exp_pm_eval(float x) {
   double xd = static_cast<double>(x);
 
   // kd = round(x * log2(e) * 2^5)
   // k_p = round(x * log2(e) * 2^5)
   // k_m = round(-x * log2(e) * 2^5)
-  double kd;
-  int k_p, k_m;
+  double kd{};
+  int k_p{}, k_m{};
 
 #ifdef LIBC_TARGET_CPU_HAS_NEAREST_INT
   kd = fputil::nearest_integer(ExpBase::LOG2_B * xd);
@@ -109,7 +109,7 @@ template <bool is_sinh> LIBC_INLINE double exp_pm_eval(float x) {
   double p_odd = fputil::polyeval(dx2, 0.5, ExpBase::COEFFS[1] * 0.5,
                                   ExpBase::COEFFS[3] * 0.5);
 
-  double r;
+  double r{};
   if constexpr (is_sinh)
     r = fputil::multiply_add(dx * mh_sum, p_odd, p_even * mh_diff);
   else
diff --git a/libc/src/__support/math/sinpif.h b/libc/src/__support/math/sinpif.h
index 926e17ba6203c..cd3d6a334994f 100644
--- a/libc/src/__support/math/sinpif.h
+++ b/libc/src/__support/math/sinpif.h
@@ -21,7 +21,7 @@
 namespace LIBC_NAMESPACE_DECL {
 namespace math {
 
-LIBC_INLINE float sinpif(float x) {
+LIBC_INLINE LIBC_CONSTEXPR float sinpif(float x) {
   using namespace sincosf_utils_internal;
   using FPBits = typename fputil::FPBits<float>;
   FPBits xbits(x);
diff --git a/libc/src/__support/math/sinpif16.h b/libc/src/__support/math/sinpif16.h
index 75d4c0c42fcc6..da9a90f81364a 100644
--- a/libc/src/__support/math/sinpif16.h
+++ b/libc/src/__support/math/sinpif16.h
@@ -25,7 +25,7 @@
 namespace LIBC_NAMESPACE_DECL {
 namespace math {
 
-LIBC_INLINE float16 sinpif16(float16 x) {
+LIBC_INLINE LIBC_CONSTEXPR float16 sinpif16(float16 x) {
   using namespace sincosf16_internal;
   using FPBits = typename fputil::FPBits<float16>;
   FPBits xbits(x);
diff --git a/libc/src/__support/math/sqrt.h b/libc/src/__support/math/sqrt.h
index baef03fca9587..0f631959653c4 100644
--- a/libc/src/__support/math/sqrt.h
+++ b/libc/src/__support/math/sqrt.h
@@ -15,7 +15,9 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE double sqrt(double x) { return fputil::sqrt<double>(x); }
+LIBC_INLINE LIBC_CONSTEXPR double sqrt(double x) {
+  return fputil::sqrt<double>(x);
+}
 
 } // namespace math
 
diff --git a/libc/src/__support/math/sqrtbf16.h b/libc/src/__support/math/sqrtbf16.h
index 365618fde892b..b0013bf2aa300 100644
--- a/libc/src/__support/math/sqrtbf16.h
+++ b/libc/src/__support/math/sqrtbf16.h
@@ -17,7 +17,9 @@
 namespace LIBC_NAMESPACE_DECL {
 namespace math {
 
-LIBC_INLINE bfloat16 sqrtbf16(bfloat16 x) { return fputil::sqrt<bfloat16>(x); }
+LIBC_INLINE constexpr bfloat16 sqrtbf16(bfloat16 x) {
+  return fputil::sqrt<bfloat16>(x);
+}
 
 } // namespace math
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/__support/math/sqrtf.h b/libc/src/__support/math/sqrtf.h
index aaa25d91ee820..d5f521d84450e 100644
--- a/libc/src/__support/math/sqrtf.h
+++ b/libc/src/__support/math/sqrtf.h
@@ -15,7 +15,9 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE float sqrtf(float x) { return fputil::sqrt<float>(x); }
+LIBC_INLINE LIBC_CONSTEXPR float sqrtf(float x) {
+  return fputil::sqrt<float>(x);
+}
 
 } // namespace math
 
diff --git a/libc/src/__support/math/tanf16.h b/libc/src/__support/math/tanf16.h
index 6b9b9224fb84d..a31cbf15c8ae2 100644
--- a/libc/src/__support/math/tanf16.h
+++ b/libc/src/__support/math/tanf16.h
@@ -27,7 +27,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE float16 tanf16(float16 x) {
+LIBC_INLINE LIBC_CONSTEXPR float16 tanf16(float16 x) {
   using namespace sincosf16_internal;
   using FPBits = fputil::FPBits<float16>;
   FPBits xbits(x);
@@ -118,7 +118,7 @@ LIBC_INLINE float16 tanf16(float16 x) {
   // Once k and y are computed, we then deduce the answer by the formula:
   // tan(x) = sin(x) / cos(x)
   // 	    = (sin_y * cos_k + cos_y * sin_k) / (cos_y * cos_k - sin_y * sin_k)
-  float sin_k, cos_k, sin_y, cosm1_y;
+  float sin_k{}, cos_k{}, sin_y{}, cosm1_y{};
   sincosf16_eval(xf, sin_k, cos_k, sin_y, cosm1_y);
 
   // Note that, cosm1_y = cos_y - 1:
diff --git a/libc/src/__support/math/tanhf16.h b/libc/src/__support/math/tanhf16.h
index 80671691203c9..50801825ffe26 100644
--- a/libc/src/__support/math/tanhf16.h
+++ b/libc/src/__support/math/tanhf16.h
@@ -32,7 +32,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE float16 tanhf16(float16 x) {
+LIBC_INLINE LIBC_CONSTEXPR float16 tanhf16(float16 x) {
   using namespace math::expxf16_internal;
   using FPBits = fputil::FPBits<float16>;
   FPBits x_bits(x);
diff --git a/libc/src/__support/math/tanpif16.h b/libc/src/__support/math/tanpif16.h
index dff6b518cc95b..b43d7f53cfc51 100644
--- a/libc/src/__support/math/tanpif16.h
+++ b/libc/src/__support/math/tanpif16.h
@@ -26,7 +26,7 @@
 namespace LIBC_NAMESPACE_DECL {
 namespace math {
 
-LIBC_INLINE float16 tanpif16(float16 x) {
+LIBC_INLINE LIBC_CONSTEXPR float16 tanpif16(float16 x) {
   using namespace sincosf16_internal;
   using FPBits = typename fputil::FPBits<float16>;
   FPBits xbits(x);
diff --git a/libc/test/shared/shared_math_constexpr_test.cpp b/libc/test/shared/shared_math_constexpr_test.cpp
index ac26ce4f0bd69..58d2806594dd2 100644
--- a/libc/test/shared/shared_math_constexpr_test.cpp
+++ b/libc/test/shared/shared_math_constexpr_test.cpp
@@ -238,7 +238,7 @@ static_assert(0 == [] {
   float16 setpayload_x = 0.0f16;
   return LIBC_NAMESPACE::shared::setpayloadf16(&setpayload_x, 0.0f16);
 }());
-static_assert(0LL == LIBC_NAMESPACE::shared::llrintf16(0.0));
+static_assert(0LL == LIBC_NAMESPACE::shared::llrintf16(0.0f16));
 static_assert(0LL == LIBC_NAMESPACE::shared::llroundf16(0.0f16));
 static_assert(0L == LIBC_NAMESPACE::shared::lrintf16(0.0f16));
 static_assert(0L == LIBC_NAMESPACE::shared::lroundf16(0.0f16));
@@ -247,15 +247,81 @@ static_assert(0.0f16 == LIBC_NAMESPACE::shared::nextafterf16(0.0f16, 0.0f16));
 static_assert(0.0f16 == LIBC_NAMESPACE::shared::rintf16(0.0f16));
 static_assert(1 == LIBC_NAMESPACE::shared::iscanonicalf16(0.0f16));
 static_assert(0.0 == LIBC_NAMESPACE::shared::issignalingf16(0.0f16));
-static_assert(1 == [] {
-  const char arg{};
-  return LIBC_NAMESPACE::fputil::FPBits<float16>(
-             LIBC_NAMESPACE::shared::nanf16(&arg))
-      .is_nan();
-}());
+static_assert(
+    LIBC_NAMESPACE::fputil::FPBits<float16>(LIBC_NAMESPACE::shared::nanf16(""))
+        .is_nan());
 static_assert(0.0f16 == LIBC_NAMESPACE::shared::roundf16(0.0f16));
 static_assert(0.0f16 == LIBC_NAMESPACE::shared::roundevenf16(0.0f16));
 static_assert(0.0f16 == LIBC_NAMESPACE::shared::truncf16(0.0f16));
+static_assert(0.0f16 == LIBC_NAMESPACE::shared::acoshf16(1.0f16));
+static_assert(0.0f16 == LIBC_NAMESPACE::shared::acospif16(1.0f16));
+static_assert(1.0f16 == LIBC_NAMESPACE::shared::rsqrtf16(1.0f16));
+static_assert(1.0f16 == LIBC_NAMESPACE::shared::sqrtf16(1.0f16));
+static_assert(0.0f16 == LIBC_NAMESPACE::shared::asinf16(0.0f16));
+static_assert(0.0f16 == LIBC_NAMESPACE::shared::asinhf16(0.0f16));
+static_assert(0.0f16 == LIBC_NAMESPACE::shared::asinpif16(0.0f16));
+static_assert(0.0f16 == LIBC_NAMESPACE::shared::atan2f16(0.0f16, 0.0f16));
+static_assert(0.0f16 == LIBC_NAMESPACE::shared::atanf16(0.0f16));
+static_assert(0.0f16 == LIBC_NAMESPACE::shared::atanhf16(0.0f16));
+static_assert(0.0f16 == LIBC_NAMESPACE::shared::atanpif16(0.0f16));
+static_assert(1.0f16 == LIBC_NAMESPACE::shared::cosf16(0.0f16));
+static_assert(1.0f16 == LIBC_NAMESPACE::shared::coshf16(0.0f16));
+static_assert(1.0f16 == LIBC_NAMESPACE::shared::cospif16(0.0f16));
+static_assert(0.0f16 == LIBC_NAMESPACE::shared::erff16(0.0f16));
+static_assert(1.0f16 == LIBC_NAMESPACE::shared::erfcf16(0.0f16));
+static_assert(1.0f16 == LIBC_NAMESPACE::shared::exp10f16(0.0f16));
+static_assert(0.0f16 == LIBC_NAMESPACE::shared::exp10m1f16(0.0f16));
+static_assert(1.0f16 == LIBC_NAMESPACE::shared::exp2f16(0.0f16));
+static_assert(0.0f16 == LIBC_NAMESPACE::shared::exp2m1f16(0.0f16));
+static_assert(1.0f16 == LIBC_NAMESPACE::shared::expf16(0.0f16));
+static_assert(0.0f16 == LIBC_NAMESPACE::shared::expm1f16(0.0f16));
+static_assert(0.0f16 == LIBC_NAMESPACE::shared::fmaf16(0.0f16, 0.0f16, 0.0f16));
+static_assert(0.0f16 == LIBC_NAMESPACE::shared::hypotf16(0.0f16, 0.0f16));
+static_assert(0.0f16 == LIBC_NAMESPACE::shared::logf16(1.0f16));
+static_assert(0.0f16 == LIBC_NAMESPACE::shared::sinhf16(0.0f16));
+static_assert(float16(8 << 5) == LIBC_NAMESPACE::shared::ldexpf16(8.0f16, 5));
+static_assert(float16(-1 * (8 << 5)) ==
+              LIBC_NAMESPACE::shared::ldexpf16(-8.0f16, 5));
+static_assert(0.75f16 == [] {
+  int exponent{};
+  return LIBC_NAMESPACE::shared::frexpf16(24.0f16, &exponent);
+}());
+static_assert(0 == LIBC_NAMESPACE::shared::ilogbf16(1.0f16));
+static_assert(1.0f16 == LIBC_NAMESPACE::shared::log10f16(10.0f16));
+static_assert(1.0f16 == LIBC_NAMESPACE::shared::log10p1f16(9.0f16));
+static_assert(1.0f16 == LIBC_NAMESPACE::shared::log2f16(2.0f16));
+static_assert(1.0f16 == LIBC_NAMESPACE::shared::log2p1f16(1.0f16));
+static_assert(0.0f16 == LIBC_NAMESPACE::shared::logbf16(1.0f16));
+static_assert(0L == LIBC_NAMESPACE::shared::llogbf16(1.0f16));
+static_assert(0.0f16 == LIBC_NAMESPACE::shared::acosf16(1.0f16));
+static_assert(0.0f16 == LIBC_NAMESPACE::shared::sinf16(0.0f16));
+static_assert(0.0f16 == LIBC_NAMESPACE::shared::tanf16(0.0f16));
+static_assert(0.0f16 == LIBC_NAMESPACE::shared::sinpif16(0.0f16));
+static_assert(0.0f16 == LIBC_NAMESPACE::shared::tanhf16(0.0f16));
+static_assert(0.0f16 == LIBC_NAMESPACE::shared::tanpif16(0.0f16));
+static_assert(0 == [] {
+  float16 canonicalizef16_cx = 0.0f16;
+  float16 canonicalizef16_x = 0.0f16;
+  return LIBC_NAMESPACE::shared::canonicalizef16(&canonicalizef16_cx,
+                                                 &canonicalizef16_x);
+}());
+static_assert(0 == [] {
+  float16 setpayloadf16_res = 0.0f16;
+  return LIBC_NAMESPACE::shared::setpayloadf16(&setpayloadf16_res, 0.0f16);
+}());
+static_assert(1 == [] {
+  float16 setpayloadsigf16_res = 0.0f16;
+  return LIBC_NAMESPACE::shared::setpayloadsigf16(&setpayloadsigf16_res,
+                                                  0.0f16);
+}());
+static_assert(LIBC_NAMESPACE::fputil::FPBits<float16>::min_subnormal(
+                  LIBC_NAMESPACE::Sign::NEG)
+                  .get_val() == LIBC_NAMESPACE::shared::nextdownf16(0.0f16));
+static_assert(LIBC_NAMESPACE::fputil::FPBits<float16>::min_subnormal(
+                  LIBC_NAMESPACE::Sign::POS)
+                  .get_val() == LIBC_NAMESPACE::shared::nextupf16(0.0f16));
+static_assert(0.0f16 == LIBC_NAMESPACE::shared::nextafterf16(0.0f16, 0.0f16));
+
 #endif // LIBC_TYPES_HAS_FLOAT16
 
 //===----------------------------------------------------------------------===//
@@ -334,6 +400,11 @@ static_assert(0L == LIBC_NAMESPACE::shared::lroundl(0.0L));
 static_assert(0.0L == LIBC_NAMESPACE::shared::nearbyintl(0.0L));
 static_assert(0.0L == LIBC_NAMESPACE::shared::nextafterl(0.0L, 0.0L));
 static_assert(0.0L == LIBC_NAMESPACE::shared::rintl(0.0L));
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+static_assert(0.0f16 == LIBC_NAMESPACE::shared::nexttowardf16(0.0f16, 0.0L));
+#endif
+
 static_assert(1 == LIBC_NAMESPACE::shared::iscanonicall(0.0L));
 static_assert(0.0 == LIBC_NAMESPACE::shared::issignalingl(0.0L));
 static_assert(1 == [] {
diff --git a/libc/test/shared/shared_math_test.cpp b/libc/test/shared/shared_math_test.cpp
index 6257ab64da666..5320d7c324827 100644
--- a/libc/test/shared/shared_math_test.cpp
+++ b/libc/test/shared/shared_math_test.cpp
@@ -20,7 +20,6 @@ TEST(LlvmLibcSharedMathTest, AllFloat16) {
   EXPECT_FP_EQ(0.0f16, LIBC_NAMESPACE::shared::acospif16(1.0f16));
   EXPECT_FP_EQ(1.0f16, LIBC_NAMESPACE::shared::rsqrtf16(1.0f16));
   EXPECT_FP_EQ(1.0f16, LIBC_NAMESPACE::shared::sqrtf16(1.0f16));
-
   EXPECT_FP_EQ(0.0f16, LIBC_NAMESPACE::shared::asinf16(0.0f16));
   EXPECT_FP_EQ(0.0f16, LIBC_NAMESPACE::shared::asinhf16(0.0f16));
   EXPECT_FP_EQ(0.0f16, LIBC_NAMESPACE::shared::asinpif16(0.0f16));
@@ -43,15 +42,12 @@ TEST(LlvmLibcSharedMathTest, AllFloat16) {
   EXPECT_FP_EQ(0.0f16, LIBC_NAMESPACE::shared::hypotf16(0.0f16, 0.0f16));
   EXPECT_FP_EQ(0.0f16, LIBC_NAMESPACE::shared::logf16(1.0f16));
   EXPECT_FP_EQ(0.0f16, LIBC_NAMESPACE::shared::sinhf16(0.0f16));
-
   ASSERT_FP_EQ(float16(8 << 5), LIBC_NAMESPACE::shared::ldexpf16(8.0f16, 5));
   ASSERT_FP_EQ(float16(-1 * (8 << 5)),
                LIBC_NAMESPACE::shared::ldexpf16(-8.0f16, 5));
-
   EXPECT_FP_EQ_ALL_ROUNDING(
       0.75f16, LIBC_NAMESPACE::shared::frexpf16(24.0f16, &exponent));
   EXPECT_EQ(exponent, 5);
-
   EXPECT_EQ(0, LIBC_NAMESPACE::shared::ilogbf16(1.0f16));
   EXPECT_FP_EQ(1.0f16, LIBC_NAMESPACE::shared::log10f16(10.0f16));
   EXPECT_FP_EQ(1.0f16, LIBC_NAMESPACE::shared::log10p1f16(9.0f16));
@@ -59,7 +55,6 @@ TEST(LlvmLibcSharedMathTest, AllFloat16) {
   EXPECT_FP_EQ(1.0f16, LIBC_NAMESPACE::shared::log2p1f16(1.0f16));
   EXPECT_FP_EQ(0.0f16, LIBC_NAMESPACE::shared::logbf16(1.0f16));
   EXPECT_EQ(0L, LIBC_NAMESPACE::shared::llogbf16(1.0f16));
-
   EXPECT_FP_EQ(0x1.921fb6p+0f16, LIBC_NAMESPACE::shared::acosf16(0.0f16));
   EXPECT_FP_EQ(0.0f16, LIBC_NAMESPACE::shared::sinf16(0.0f16));
   EXPECT_FP_EQ(0.0f16, LIBC_NAMESPACE::shared::tanf16(0.0f16));

>From d323cfd1b4905c083f7ca6ee1cf61f058334a9f4 Mon Sep 17 00:00:00 2001
From: bassiounix <muhammad.m.bassiouni at gmail.com>
Date: Mon, 4 May 2026 14:32:36 +0300
Subject: [PATCH 2/2] all floats

---
 libc/src/__support/FPUtil/double_double.h     | 12 +--
 libc/src/__support/FPUtil/generic/FMA.h       |  5 +-
 libc/src/__support/math/acospif.h             |  2 +-
 libc/src/__support/math/asinpif.h             |  2 +-
 libc/src/__support/math/inv_trigf_utils.h     |  2 +-
 libc/src/__support/math/log10f.h              |  2 +-
 libc/src/__support/math/log2f.h               |  2 +-
 libc/src/__support/math/logf.h                |  2 +-
 libc/src/__support/math/powf.h                |  8 +-
 libc/src/__support/math/sincosf.h             |  2 +-
 libc/src/__support/math/sinf.h                |  4 +-
 libc/src/__support/math/tanf.h                |  4 +-
 libc/src/__support/math/tanhf.h               |  2 +-
 libc/src/__support/math/tanpif.h              |  4 +-
 .../shared/shared_math_constexpr_test.cpp     | 77 +++++++++++++++++++
 15 files changed, 104 insertions(+), 26 deletions(-)

diff --git a/libc/src/__support/FPUtil/double_double.h b/libc/src/__support/FPUtil/double_double.h
index 31049ced5a934..31147759602ba 100644
--- a/libc/src/__support/FPUtil/double_double.h
+++ b/libc/src/__support/FPUtil/double_double.h
@@ -146,15 +146,16 @@ LIBC_INLINE LIBC_CONSTEXPR NumberPair<T> exact_mult(T a, T b) {
 }
 
 template <typename T = double>
-LIBC_INLINE NumberPair<T> quick_mult(T a, const NumberPair<T> &b) {
+LIBC_INLINE LIBC_CONSTEXPR NumberPair<T> quick_mult(T a,
+                                                    const NumberPair<T> &b) {
   NumberPair<T> r = exact_mult(a, b.hi);
   r.lo = multiply_add(a, b.lo, r.lo);
   return r;
 }
 
 template <size_t SPLIT_B = 27>
-LIBC_INLINE constexpr DoubleDouble quick_mult(const DoubleDouble &a,
-                                              const DoubleDouble &b) {
+LIBC_INLINE LIBC_CONSTEXPR DoubleDouble quick_mult(const DoubleDouble &a,
+                                                   const DoubleDouble &b) {
   DoubleDouble r = exact_mult<double, SPLIT_B>(a.hi, b.hi);
   double t1 = multiply_add(a.hi, b.lo, r.lo);
   double t2 = multiply_add(a.lo, b.hi, t1);
@@ -164,9 +165,8 @@ LIBC_INLINE constexpr DoubleDouble quick_mult(const DoubleDouble &a,
 
 // Assuming |c| >= |a * b|.
 template <>
-LIBC_INLINE DoubleDouble multiply_add<DoubleDouble>(const DoubleDouble &a,
-                                                    const DoubleDouble &b,
-                                                    const DoubleDouble &c) {
+LIBC_INLINE LIBC_CONSTEXPR DoubleDouble multiply_add<DoubleDouble>(
+    const DoubleDouble &a, const DoubleDouble &b, const DoubleDouble &c) {
   return add(c, quick_mult(a, b));
 }
 
diff --git a/libc/src/__support/FPUtil/generic/FMA.h b/libc/src/__support/FPUtil/generic/FMA.h
index 896d6695ec6f4..8b51949afc6d1 100644
--- a/libc/src/__support/FPUtil/generic/FMA.h
+++ b/libc/src/__support/FPUtil/generic/FMA.h
@@ -38,7 +38,7 @@ fma(InType x, InType y, InType z);
 // TODO(lntue): Implement fmaf that is correctly rounded to all rounding modes.
 // The implementation below only is only correct for the default rounding mode,
 // round-to-nearest tie-to-even.
-template <> LIBC_INLINE float fma<float>(float x, float y, float z) {
+template <> LIBC_INLINE constexpr float fma<float>(float x, float y, float z) {
   // Product is exact.
   double prod = static_cast<double>(x) * static_cast<double>(y);
   double z_d = static_cast<double>(z);
@@ -90,7 +90,8 @@ namespace internal {
 // Extract the sticky bits and shift the `mantissa` to the right by
 // `shift_length`.
 template <typename T>
-LIBC_INLINE cpp::enable_if_t<is_unsigned_integral_or_big_int_v<T>, bool>
+LIBC_INLINE constexpr cpp::enable_if_t<is_unsigned_integral_or_big_int_v<T>,
+                                       bool>
 shift_mantissa(int shift_length, T &mant) {
   if (shift_length >= cpp::numeric_limits<T>::digits) {
     mant = 0;
diff --git a/libc/src/__support/math/acospif.h b/libc/src/__support/math/acospif.h
index acf2b9748975b..5a0bf6953e8aa 100644
--- a/libc/src/__support/math/acospif.h
+++ b/libc/src/__support/math/acospif.h
@@ -21,7 +21,7 @@
 namespace LIBC_NAMESPACE_DECL {
 namespace math {
 
-LIBC_INLINE float acospif(float x) {
+LIBC_INLINE LIBC_CONSTEXPR float acospif(float x) {
   using FPBits = fputil::FPBits<float>;
 
   FPBits xbits(x);
diff --git a/libc/src/__support/math/asinpif.h b/libc/src/__support/math/asinpif.h
index 79d3ebbe63b5b..409f0700619f6 100644
--- a/libc/src/__support/math/asinpif.h
+++ b/libc/src/__support/math/asinpif.h
@@ -22,7 +22,7 @@
 namespace LIBC_NAMESPACE_DECL {
 namespace math {
 
-LIBC_INLINE float asinpif(float x) {
+LIBC_INLINE LIBC_CONSTEXPR float asinpif(float x) {
   using FPBits = fputil::FPBits<float>;
 
   FPBits xbits(x);
diff --git a/libc/src/__support/math/inv_trigf_utils.h b/libc/src/__support/math/inv_trigf_utils.h
index e30eaeb3a3f9a..e209c8f2b672b 100644
--- a/libc/src/__support/math/inv_trigf_utils.h
+++ b/libc/src/__support/math/inv_trigf_utils.h
@@ -235,7 +235,7 @@ constexpr double ASINPI_COEFFS[13] = {
 //     r0 = q0 + q1*v8        r1 = q2
 //   Level 3 (using v16):
 //     result = r0 + r1*v16
-LIBC_INLINE double asinpi_eval(double v2) {
+LIBC_INLINE LIBC_CONSTEXPR double asinpi_eval(double v2) {
   double v4 = v2 * v2;
   double v8 = v4 * v4;
   double v16 = v8 * v8;
diff --git a/libc/src/__support/math/log10f.h b/libc/src/__support/math/log10f.h
index 1869a208393d6..ffd71d4d9f1e1 100644
--- a/libc/src/__support/math/log10f.h
+++ b/libc/src/__support/math/log10f.h
@@ -61,7 +61,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE float log10f(float x) {
+LIBC_INLINE LIBC_CONSTEXPR float log10f(float x) {
   using namespace common_constants_internal;
   constexpr double LOG10_2 = 0x1.34413509f79ffp-2;
   // Lookup table for -log10(r) where r is defined in common_constants.cpp.
diff --git a/libc/src/__support/math/log2f.h b/libc/src/__support/math/log2f.h
index 138dd9fa29e03..0242dcbf38429 100644
--- a/libc/src/__support/math/log2f.h
+++ b/libc/src/__support/math/log2f.h
@@ -58,7 +58,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE float log2f(float x) {
+LIBC_INLINE LIBC_CONSTEXPR float log2f(float x) {
   using namespace common_constants_internal;
   using FPBits = typename fputil::FPBits<float>;
 
diff --git a/libc/src/__support/math/logf.h b/libc/src/__support/math/logf.h
index 09baa283cb120..a704e1e695ea8 100644
--- a/libc/src/__support/math/logf.h
+++ b/libc/src/__support/math/logf.h
@@ -56,7 +56,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE float logf(float x) {
+LIBC_INLINE LIBC_CONSTEXPR float logf(float x) {
   using namespace common_constants_internal;
   constexpr double LOG_2 = 0x1.62e42fefa39efp-1;
   using FPBits = typename fputil::FPBits<float>;
diff --git a/libc/src/__support/math/powf.h b/libc/src/__support/math/powf.h
index 5762309794d27..ce9a98ea27122 100644
--- a/libc/src/__support/math/powf.h
+++ b/libc/src/__support/math/powf.h
@@ -569,9 +569,9 @@ LIBC_INLINE constexpr bool larger_exponent(double a, double b) {
 //   y6: 2^6 * y.
 //   lo6_hi: the high part of 2^6 * (y - (hi + mid))
 //   exp2_hi_mid: high part of 2^(hi + mid)
-LIBC_INLINE double powf_double_double(int idx_x, double dx, double y6,
-                                      double lo6_hi,
-                                      const DoubleDouble &exp2_hi_mid) {
+LIBC_INLINE LIBC_CONSTEXPR double
+powf_double_double(int idx_x, double dx, double y6, double lo6_hi,
+                   const DoubleDouble &exp2_hi_mid) {
   using DoubleBits = typename fputil::FPBits<double>;
 
   // Perform a second range reduction step:
@@ -661,7 +661,7 @@ LIBC_INLINE double powf_double_double(int idx_x, double dx, double y6,
 
 } // namespace powf_internal
 
-LIBC_INLINE float powf(float x, float y) {
+LIBC_INLINE LIBC_CONSTEXPR float powf(float x, float y) {
   using namespace powf_internal;
   using FloatBits = typename fputil::FPBits<float>;
   using DoubleBits [[maybe_unused]] = typename fputil::FPBits<double>;
diff --git a/libc/src/__support/math/sincosf.h b/libc/src/__support/math/sincosf.h
index a6b1cd8ae3010..faabcd0fa4bc8 100644
--- a/libc/src/__support/math/sincosf.h
+++ b/libc/src/__support/math/sincosf.h
@@ -58,7 +58,7 @@ LIBC_INLINE_VAR constexpr uint32_t EXCEPT_OUTPUTS_COS[N_EXCEPTS][4] = {
 #endif // !LIBC_MATH_HAS_SKIP_ACCURATE_PASS
 } // namespace sincosf_internal
 
-LIBC_INLINE void sincosf(float x, float *sinp, float *cosp) {
+LIBC_INLINE LIBC_CONSTEXPR void sincosf(float x, float *sinp, float *cosp) {
   using namespace sincosf_internal;
   using namespace sincosf_utils_internal;
   using FPBits = typename fputil::FPBits<float>;
diff --git a/libc/src/__support/math/sinf.h b/libc/src/__support/math/sinf.h
index 23b3a39920d64..b029f1d57c89c 100644
--- a/libc/src/__support/math/sinf.h
+++ b/libc/src/__support/math/sinf.h
@@ -51,7 +51,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE float sinf(float x) {
+LIBC_INLINE LIBC_CONSTEXPR float sinf(float x) {
   using namespace sincosf_utils_internal;
   using FPBits = typename fputil::FPBits<float>;
   FPBits xbits(x);
@@ -178,7 +178,7 @@ LIBC_INLINE float sinf(float x) {
   //          = sin(y*pi/32) * cos(k*pi/32) + cos(y*pi/32) * sin(k*pi/32)
   //          = sin_y * cos_k + (1 + cosm1_y) * sin_k
   //          = sin_y * cos_k + (cosm1_y * sin_k + sin_k)
-  double sin_k, cos_k, sin_y, cosm1_y;
+  double sin_k{}, cos_k{}, sin_y{}, cosm1_y{};
 
   sincosf_eval(xd, x_abs, sin_k, cos_k, sin_y, cosm1_y);
 
diff --git a/libc/src/__support/math/tanf.h b/libc/src/__support/math/tanf.h
index 3a1d8e8bd53b6..0b80748026d38 100644
--- a/libc/src/__support/math/tanf.h
+++ b/libc/src/__support/math/tanf.h
@@ -49,7 +49,7 @@ LIBC_INLINE_VAR constexpr fputil::ExceptValues<float, N_EXCEPTS> TANF_EXCEPTS{{
 
 } // namespace tanf_internal
 
-LIBC_INLINE float tanf(float x) {
+LIBC_INLINE LIBC_CONSTEXPR float tanf(float x) {
   using namespace sincosf_utils_internal;
   using namespace tanf_internal;
   using FPBits = typename fputil::FPBits<float>;
@@ -147,7 +147,7 @@ LIBC_INLINE float tanf(float x) {
   // and sincosf.
 
   double xd = static_cast<double>(x);
-  double sin_k, cos_k, sin_y, cosm1_y;
+  double sin_k{}, cos_k{}, sin_y{}, cosm1_y{};
 
   sincosf_eval(xd, x_abs, sin_k, cos_k, sin_y, cosm1_y);
   // tan(x) = sin(x) / cos(x)
diff --git a/libc/src/__support/math/tanhf.h b/libc/src/__support/math/tanhf.h
index 15c86c6b25f5f..b707b010feb03 100644
--- a/libc/src/__support/math/tanhf.h
+++ b/libc/src/__support/math/tanhf.h
@@ -22,7 +22,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE float tanhf(float x) {
+LIBC_INLINE LIBC_CONSTEXPR float tanhf(float x) {
   // 2^6 * log2(e)
   constexpr double LOG2_E_EXP2_6 = ExpBase::LOG2_B * 2.0;
 
diff --git a/libc/src/__support/math/tanpif.h b/libc/src/__support/math/tanpif.h
index 114fcb6053d30..5fd96e38ad509 100644
--- a/libc/src/__support/math/tanpif.h
+++ b/libc/src/__support/math/tanpif.h
@@ -23,7 +23,7 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE float tanpif(float x) {
+LIBC_INLINE LIBC_CONSTEXPR float tanpif(float x) {
   using namespace sincosf_utils_internal;
 
   using FPBits = typename fputil::FPBits<float>;
@@ -91,7 +91,7 @@ LIBC_INLINE float tanpif(float x) {
   // Once k and y are computed, we then deduce the answer by the formula:
   // tan(x) = sin(x) / cos(x)
   //        = (sin_y * cos_k + cos_y * sin_k) / (cos_y * cos_k - sin_y * sin_k)
-  double sin_k, cos_k, sin_y, cosm1_y;
+  double sin_k{}, cos_k{}, sin_y{}, cosm1_y{};
   sincospif_eval(xd, sin_k, cos_k, sin_y, cosm1_y);
 
   if (LIBC_UNLIKELY(sin_y == 0 && cos_k == 0)) {
diff --git a/libc/test/shared/shared_math_constexpr_test.cpp b/libc/test/shared/shared_math_constexpr_test.cpp
index bf7506beadc91..56d382548d010 100644
--- a/libc/test/shared/shared_math_constexpr_test.cpp
+++ b/libc/test/shared/shared_math_constexpr_test.cpp
@@ -174,6 +174,82 @@ static_assert(0.0f == LIBC_NAMESPACE::shared::roundf(0.0f));
 static_assert(0.0f == LIBC_NAMESPACE::shared::roundevenf(0.0f));
 static_assert(0.0f == LIBC_NAMESPACE::shared::truncf(0.0f));
 static_assert(0 == LIBC_NAMESPACE::shared::isnanf(0.0f));
+static_assert(0.0f == LIBC_NAMESPACE::shared::acosf(1.0f));
+static_assert(0.0f == LIBC_NAMESPACE::shared::acoshf(1.0f));
+static_assert(0.0f == LIBC_NAMESPACE::shared::acospif(1.0f));
+static_assert(0.0f == LIBC_NAMESPACE::shared::asinf(0.0f));
+static_assert(0.0f == LIBC_NAMESPACE::shared::asinhf(0.0f));
+static_assert(0.0f == LIBC_NAMESPACE::shared::asinpif(0.0f));
+static_assert(0.0f == LIBC_NAMESPACE::shared::atan2f(0.0f, 0.0f));
+static_assert(0.0f == LIBC_NAMESPACE::shared::atanf(0.0f));
+static_assert(0.0f == LIBC_NAMESPACE::shared::atanhf(0.0f));
+static_assert(0.0f == LIBC_NAMESPACE::shared::cbrtf(0.0f));
+static_assert(1.0f == LIBC_NAMESPACE::shared::cosf(0.0f));
+static_assert(1.0f == LIBC_NAMESPACE::shared::coshf(0.0f));
+static_assert(1.0f == LIBC_NAMESPACE::shared::cospif(0.0f));
+static_assert(0.0f == LIBC_NAMESPACE::shared::exp10m1f(0.0f));
+static_assert(0.0f == LIBC_NAMESPACE::shared::erff(0.0f));
+static_assert(1.0f == LIBC_NAMESPACE::shared::exp10f(0.0f));
+static_assert(0.0f == LIBC_NAMESPACE::shared::exp2m1f(0.0f));
+static_assert(1.0f == LIBC_NAMESPACE::shared::expf(0.0f));
+static_assert(1.0f == LIBC_NAMESPACE::shared::exp2f(0.0f));
+static_assert(0.0f == LIBC_NAMESPACE::shared::expm1f(0.0f));
+static_assert(0.0f == LIBC_NAMESPACE::shared::fmaf(0.0f, 0.0f, 0.0f));
+static_assert(0.0f == LIBC_NAMESPACE::shared::hypotf(0.0f, 0.0f));
+static_assert(0.0f == LIBC_NAMESPACE::shared::logf(1.0f));
+static_assert(0.0f == LIBC_NAMESPACE::shared::sinhf(0.0f));
+static_assert(0.75f == [] {
+  int exponent{};
+  return LIBC_NAMESPACE::shared::frexpf(24.0f, &exponent);
+}());
+static_assert(0 == LIBC_NAMESPACE::shared::ilogbf(1.0f));
+static_assert(float(8 << 5) == LIBC_NAMESPACE::shared::ldexpf(8.0f, 5));
+static_assert(float(-1 * (8 << 5)) == LIBC_NAMESPACE::shared::ldexpf(-8.0f, 5));
+static_assert(0L == LIBC_NAMESPACE::shared::llogbf(1.0f));
+static_assert(0.0f == LIBC_NAMESPACE::shared::log1pf(0.0f));
+static_assert(1.0f == LIBC_NAMESPACE::shared::log10f(10.0f));
+static_assert(1.0f == LIBC_NAMESPACE::shared::log2f(2.0f));
+static_assert(0.0f == LIBC_NAMESPACE::shared::logbf(1.0f));
+static_assert(1.0f == LIBC_NAMESPACE::shared::powf(0.0f, 0.0f));
+static_assert(1.0f == LIBC_NAMESPACE::shared::rsqrtf(1.0f));
+static_assert([] {
+  float s{}, c{};
+  LIBC_NAMESPACE::shared::sincosf(0.0f, &s, &c);
+  return s == 0.0f && c == 1.0f;
+}());
+static_assert(0.0f == LIBC_NAMESPACE::shared::sinpif(0.0f));
+static_assert(0.0f == LIBC_NAMESPACE::shared::sinf(0.0f));
+static_assert(0.0f == LIBC_NAMESPACE::shared::sqrtf(0.0f));
+static_assert(0.0f == LIBC_NAMESPACE::shared::tanf(0.0f));
+static_assert(0.0f == LIBC_NAMESPACE::shared::tanhf(0.0f));
+static_assert(0.0f == LIBC_NAMESPACE::shared::tanpif(0.0f));
+static_assert(bfloat16(5.0f) == LIBC_NAMESPACE::shared::bf16addf(2.0f, 3.0f));
+static_assert(bfloat16(2.0f) == LIBC_NAMESPACE::shared::bf16divf(4.0f, 2.0f));
+static_assert(bfloat16(0.0f) == LIBC_NAMESPACE::shared::bf16mulf(0.0f, 0.0f));
+static_assert(bfloat16(0.0f) == LIBC_NAMESPACE::shared::bf16subf(0.0f, 0.0f));
+static_assert(bfloat16(10.0f) ==
+              LIBC_NAMESPACE::shared::bf16fmaf(2.0f, 3.0f, 4.0f));
+static_assert(1 == [] {
+  float setpayloadsigf_res = 0.0f;
+  auto res = LIBC_NAMESPACE::shared::setpayloadsigf(&setpayloadsigf_res, 0.0f);
+  return res == 1 && setpayloadsigf_res == 0.0f;
+}());
+static_assert(LIBC_NAMESPACE::fputil::FPBits<float>::min_subnormal(
+                  LIBC_NAMESPACE::Sign::NEG)
+                  .get_val() == LIBC_NAMESPACE::shared::nextdownf(0.0f));
+static_assert(LIBC_NAMESPACE::fputil::FPBits<float>::min_subnormal(
+                  LIBC_NAMESPACE::Sign ::POS)
+                  .get_val() == LIBC_NAMESPACE::shared::nextupf(0.0f));
+static_assert(0.0f == LIBC_NAMESPACE::shared::nextafterf(0.0f, 0.0f));
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+static_assert(5.0f16 == LIBC_NAMESPACE::shared::f16addf(2.0f, 3.0f));
+static_assert(0.0f16 == LIBC_NAMESPACE::shared::f16divf(0.0f, 1.0f));
+static_assert(0.0f16 == LIBC_NAMESPACE::shared::f16mulf(0.0f, 0.0f));
+static_assert(0.0f16 == LIBC_NAMESPACE::shared::f16subf(0.0f, 0.0f));
+static_assert(0.0f16 == LIBC_NAMESPACE::shared::f16sqrtf(0.0f));
+static_assert(10.0f16 == LIBC_NAMESPACE::shared::f16fmaf(2.0f, 3.0f, 4.0f));
+#endif // LIBC_TYPES_HAS_FLOAT16
 
 //===----------------------------------------------------------------------===//
 //                       Float16 Tests
@@ -429,6 +505,7 @@ static_assert(0.0L == LIBC_NAMESPACE::shared::roundl(0.0L));
 static_assert(0.0L == LIBC_NAMESPACE::shared::roundevenl(0.0L));
 static_assert(0.0L == LIBC_NAMESPACE::shared::truncl(0.0L));
 static_assert(0 == LIBC_NAMESPACE::shared::isnanl(0.0L));
+static_assert(0.0f == LIBC_NAMESPACE::shared::nexttowardf(0.0f, 0.0L));
 
 #endif
 



More information about the libc-commits mailing list