[libc-commits] [libc] [llvm] [libc][math][c23] Add hypotbf16 function (PR #183460)

via libc-commits libc-commits at lists.llvm.org
Sun Mar 1 21:36:06 PST 2026


https://github.com/Sukumarsawant updated https://github.com/llvm/llvm-project/pull/183460

>From 3c069303fdcd54fb0a668bd95eabee04361c9550 Mon Sep 17 00:00:00 2001
From: Sukumarsawant <sawantsukumar at gmail.com>
Date: Wed, 25 Feb 2026 10:06:58 +0530
Subject: [PATCH 01/19] configs

---
 libc/config/baremetal/aarch64/entrypoints.txt | 1 +
 libc/config/baremetal/arm/entrypoints.txt     | 1 +
 libc/config/baremetal/riscv/entrypoints.txt   | 1 +
 libc/config/darwin/aarch64/entrypoints.txt    | 1 +
 libc/config/darwin/x86_64/entrypoints.txt     | 1 +
 libc/config/gpu/amdgpu/entrypoints.txt        | 1 +
 libc/config/gpu/nvptx/entrypoints.txt         | 1 +
 libc/config/linux/aarch64/entrypoints.txt     | 1 +
 libc/config/linux/arm/entrypoints.txt         | 1 +
 libc/config/linux/riscv/entrypoints.txt       | 1 +
 libc/config/linux/x86_64/entrypoints.txt      | 1 +
 libc/config/windows/entrypoints.txt           | 1 +
 12 files changed, 12 insertions(+)

diff --git a/libc/config/baremetal/aarch64/entrypoints.txt b/libc/config/baremetal/aarch64/entrypoints.txt
index 742d96761c415..a89f9bd65a043 100644
--- a/libc/config/baremetal/aarch64/entrypoints.txt
+++ b/libc/config/baremetal/aarch64/entrypoints.txt
@@ -447,6 +447,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.getpayloadf
     libc.src.math.getpayloadl
     libc.src.math.hypot
+    libc.src.math.hypotbf16
     libc.src.math.hypotf
     libc.src.math.ilogb
     libc.src.math.ilogbf
diff --git a/libc/config/baremetal/arm/entrypoints.txt b/libc/config/baremetal/arm/entrypoints.txt
index 95cb0dea8e49e..4470208c6f211 100644
--- a/libc/config/baremetal/arm/entrypoints.txt
+++ b/libc/config/baremetal/arm/entrypoints.txt
@@ -450,6 +450,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.getpayloadf
     libc.src.math.getpayloadl
     libc.src.math.hypot
+    libc.src.math.hypotbf16
     libc.src.math.hypotf
     libc.src.math.ilogb
     libc.src.math.ilogbf
diff --git a/libc/config/baremetal/riscv/entrypoints.txt b/libc/config/baremetal/riscv/entrypoints.txt
index 3fc71280f5163..b23e8d71bac81 100644
--- a/libc/config/baremetal/riscv/entrypoints.txt
+++ b/libc/config/baremetal/riscv/entrypoints.txt
@@ -448,6 +448,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.getpayloadf
     libc.src.math.getpayloadl
     libc.src.math.hypot
+    libc.src.math.hypotbf16
     libc.src.math.hypotf
     libc.src.math.ilogb
     libc.src.math.ilogbf
diff --git a/libc/config/darwin/aarch64/entrypoints.txt b/libc/config/darwin/aarch64/entrypoints.txt
index 3909417f9730d..7f7a22fded002 100644
--- a/libc/config/darwin/aarch64/entrypoints.txt
+++ b/libc/config/darwin/aarch64/entrypoints.txt
@@ -263,6 +263,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.getpayloadf
     libc.src.math.getpayloadl
     libc.src.math.hypot
+    libc.src.math.hypotbf16
     libc.src.math.hypotf
     libc.src.math.ilogb
     libc.src.math.ilogbf
diff --git a/libc/config/darwin/x86_64/entrypoints.txt b/libc/config/darwin/x86_64/entrypoints.txt
index e899bf97ea3f6..3d205b5a10895 100644
--- a/libc/config/darwin/x86_64/entrypoints.txt
+++ b/libc/config/darwin/x86_64/entrypoints.txt
@@ -162,6 +162,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     #libc.src.math.fsub
     #libc.src.math.fsubl
     #libc.src.math.hypot
+    #libc.src.math.hypotbf16
     #libc.src.math.hypotf
     #libc.src.math.ilogb
     #libc.src.math.ilogbf
diff --git a/libc/config/gpu/amdgpu/entrypoints.txt b/libc/config/gpu/amdgpu/entrypoints.txt
index 0dda7d5c683ec..39da9588ea28e 100644
--- a/libc/config/gpu/amdgpu/entrypoints.txt
+++ b/libc/config/gpu/amdgpu/entrypoints.txt
@@ -390,6 +390,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.getpayloadf
     libc.src.math.getpayloadl
     libc.src.math.hypot
+    libc.src.math.hypotbf16
     libc.src.math.hypotf
     libc.src.math.ilogb
     libc.src.math.ilogbf
diff --git a/libc/config/gpu/nvptx/entrypoints.txt b/libc/config/gpu/nvptx/entrypoints.txt
index 6070fb5b17b3c..bfc562ba01c36 100644
--- a/libc/config/gpu/nvptx/entrypoints.txt
+++ b/libc/config/gpu/nvptx/entrypoints.txt
@@ -391,6 +391,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.getpayloadf
     libc.src.math.getpayloadl
     libc.src.math.hypot
+    libc.src.math.hypotbf16
     libc.src.math.hypotf
     libc.src.math.ilogb
     libc.src.math.ilogbf
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index 0d99a2d63d249..b4483c2e67516 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -528,6 +528,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.getpayloadf
     libc.src.math.getpayloadl
     libc.src.math.hypot
+    libc.src.math.hypotbf16
     libc.src.math.hypotf
     libc.src.math.ilogb
     libc.src.math.ilogbf
diff --git a/libc/config/linux/arm/entrypoints.txt b/libc/config/linux/arm/entrypoints.txt
index f04ac40145d3a..7c3c932663de9 100644
--- a/libc/config/linux/arm/entrypoints.txt
+++ b/libc/config/linux/arm/entrypoints.txt
@@ -349,6 +349,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.getpayloadf
     libc.src.math.getpayloadl
     libc.src.math.hypot
+    libc.src.math.hypotbf16
     libc.src.math.hypotf
     libc.src.math.ilogb
     libc.src.math.ilogbf
diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt
index 7baf4de9d8a5b..edede92ed9565 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -537,6 +537,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.getpayloadf
     libc.src.math.getpayloadl
     libc.src.math.hypot
+    libc.src.math.hypotbf16
     libc.src.math.hypotf
     libc.src.math.ilogb
     libc.src.math.ilogbf
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index 6485c24f5736a..04ad792d30512 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -579,6 +579,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.getpayloadf
     libc.src.math.getpayloadl
     libc.src.math.hypot
+    libc.src.math.hypotbf16
     libc.src.math.hypotf
     libc.src.math.ilogb
     libc.src.math.ilogbf
diff --git a/libc/config/windows/entrypoints.txt b/libc/config/windows/entrypoints.txt
index 3a76595b258e2..474e970e4678d 100644
--- a/libc/config/windows/entrypoints.txt
+++ b/libc/config/windows/entrypoints.txt
@@ -222,6 +222,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.fsub
     libc.src.math.fsubl
     libc.src.math.hypot
+    libc.src.math.hypotbf16
     libc.src.math.hypotf
     libc.src.math.ilogb
     libc.src.math.ilogbf

>From 086a0a85b685ac600952841ed1ea78faa89564e7 Mon Sep 17 00:00:00 2001
From: Sukumarsawant <sawantsukumar at gmail.com>
Date: Wed, 25 Feb 2026 10:30:19 +0530
Subject: [PATCH 02/19] initial

---
 libc/src/math/generic/CMakeLists.txt | 11 +++++++++++
 libc/src/math/generic/hypotbf16.cpp  | 18 ++++++++++++++++++
 2 files changed, 29 insertions(+)
 create mode 100644 libc/src/math/generic/hypotbf16.cpp

diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index b66382ef09d82..13a40e5c678b0 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -3040,6 +3040,17 @@ add_entrypoint_object(
     libc.src.__support.macros.config
 )
 
+add_entrypoint_object(
+  hypotbf16
+  SRCS
+    hypotbf16.cpp
+  HDRS
+    ../hypotbf16.h
+  DEPENDS
+    libc.src.__support.math.hypotbf16
+    libc.src.math.hypotbf16
+)
+
 add_entrypoint_object(
   hypotf
   SRCS
diff --git a/libc/src/math/generic/hypotbf16.cpp b/libc/src/math/generic/hypotbf16.cpp
new file mode 100644
index 0000000000000..78ecc51dfb4ce
--- /dev/null
+++ b/libc/src/math/generic/hypotbf16.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of hypotbf16 function -------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+#include "src/math/hypotbf16.h"
+#include "src/__support/math/hypotbf16.h"
+#include "src/__support/FPUtil/bfloat16.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(BFloat16, hypotf, (BFloat16 x, BFloat16 y)) {
+  return math::hypotf(x, y);
+}
+
+} // namespace LIBC_NAMESPACE_DECL

>From 91383779ff161a9481299ea3f53110639247f525 Mon Sep 17 00:00:00 2001
From: Sukumarsawant <sawantsukumar at gmail.com>
Date: Thu, 26 Feb 2026 00:13:08 +0530
Subject: [PATCH 03/19] exhaustive test added [positive range + special] +
 implemented +smoke tests

---
 libc/docs/headers/math/index.rst            |   2 +-
 libc/src/__support/math/hypotbf16.h         | 102 ++++++++++++++++++++
 libc/src/math/CMakeLists.txt                |   1 +
 libc/src/math/generic/hypotbf16.cpp         |   6 +-
 libc/src/math/hypotbf16.h                   |  21 ++++
 libc/test/src/math/CMakeLists.txt           |  13 +++
 libc/test/src/math/hypotbf16_test.cpp       |  52 ++++++++++
 libc/test/src/math/smoke/CMakeLists.txt     |  13 +++
 libc/test/src/math/smoke/hypotbf16_test.cpp |  17 ++++
 libc/utils/MPFRWrapper/MPFRUtils.cpp        |   4 +-
 10 files changed, 225 insertions(+), 6 deletions(-)
 create mode 100644 libc/src/__support/math/hypotbf16.h
 create mode 100644 libc/src/math/hypotbf16.h
 create mode 100644 libc/test/src/math/hypotbf16_test.cpp
 create mode 100644 libc/test/src/math/smoke/hypotbf16_test.cpp

diff --git a/libc/docs/headers/math/index.rst b/libc/docs/headers/math/index.rst
index 4b443e3e49ddb..166fe84407a73 100644
--- a/libc/docs/headers/math/index.rst
+++ b/libc/docs/headers/math/index.rst
@@ -319,7 +319,7 @@ Higher Math Functions
 +-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+
 | fsqrt     | N/A              | |check|         |  |check|               | N/A                  | |check|\*              |                        | 7.12.14.6              | F.10.11                    |
 +-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+
-| hypot     | |check|          | |check|         |                        | |check|              |                        |                        | 7.12.7.4               | F.10.4.4                   |
+| hypot     | |check|          | |check|         |                        | |check|              |                        | |check|                | 7.12.7.4               | F.10.4.4                   |
 +-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+
 | lgamma    |                  |                 |                        |                      |                        |                        | 7.12.8.3               | F.10.5.3                   |
 +-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+
diff --git a/libc/src/__support/math/hypotbf16.h b/libc/src/__support/math/hypotbf16.h
new file mode 100644
index 0000000000000..476021386b535
--- /dev/null
+++ b/libc/src/__support/math/hypotbf16.h
@@ -0,0 +1,102 @@
+//===-- Implementation header for hypotbf16 ---------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_HYPOTBF16_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_HYPOTBF16_H
+
+#include "src/__support/FPUtil/FEnvImpl.h"
+#include "src/__support/FPUtil/FPBits.h"
+#include "src/__support/FPUtil/cast.h"
+#include "src/__support/FPUtil/multiply_add.h"
+#include "src/__support/FPUtil/sqrt.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/optimization.h"
+#include "src/__support/macros/properties/types.h"
+#include "src/__support/FPUtil/bfloat16.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+constexpr bfloat16 zero = bfloat16(0.0f);
+
+// For targets where conversion from float to float16 has to be
+// emulated, fputil::hypot<float16> is faster
+LIBC_INLINE bfloat16 hypotbf16(bfloat16 x, bfloat16 y) {
+  using FloatBits = fputil::FPBits<bfloat16>;
+  using FPBits = fputil::FPBits<bfloat16>;
+
+  FPBits x_abs = FPBits(x).abs();
+  FPBits y_abs = FPBits(y).abs();
+
+  bool x_abs_larger = x_abs.uintval() >= y_abs.uintval();
+
+  FPBits a_bits = x_abs_larger ? x_abs : y_abs;
+  FPBits b_bits = x_abs_larger ? y_abs : x_abs;
+
+  uint16_t a_u = a_bits.uintval();
+  uint16_t b_u = b_bits.uintval();
+
+  // Note: replacing `a_u >= FPBits::EXP_MASK` with `a_bits.is_inf_or_nan()`
+  // generates extra exponent bit masking instructions on x86-64.
+  if (LIBC_UNLIKELY(a_u >= FPBits::EXP_MASK)) {
+    // x or y is inf or nan
+    if (a_bits.is_signaling_nan() || b_bits.is_signaling_nan()) {
+      fputil::raise_except_if_required(FE_INVALID);
+      return FPBits::quiet_nan().get_val();
+    }
+    if (a_bits.is_inf() || b_bits.is_inf())
+      return FPBits::inf().get_val();
+    return a_bits.get_val();
+  }
+
+  bfloat16 af = fputil::cast<bfloat16>(a_bits.get_val());
+  bfloat16 bf = fputil::cast<bfloat16>(b_bits.get_val());
+
+  // Compiler runtime basic operations for float16 might not be correctly
+  // rounded for all rounding modes.
+  if (LIBC_UNLIKELY(a_u - b_u >=
+                    static_cast<uint16_t>((FPBits::FRACTION_LEN + 2)
+                                          << FPBits::FRACTION_LEN)))
+    return fputil::cast<bfloat16>(af + bf);
+
+  // These squares are exact.
+  bfloat16 a_sq = af * af;
+  bfloat16 sum_sq = fputil::multiply_add(bf, bf, a_sq);
+
+  FloatBits result(fputil::sqrt<bfloat16>(sum_sq));
+  uint32_t r_u = result.uintval();
+
+  // If any of the sticky bits of the result are non-zero, except the LSB, then
+  // the rounded result is correct.
+  if (LIBC_UNLIKELY(((r_u + 1) & 0x0000'0FFE) == 0)) {
+    bfloat16 r_d = result.get_val();
+
+    // Perform rounding correction.
+    bfloat16 sum_sq_lo = fputil::multiply_add(bf, bf, a_sq - sum_sq);
+    bfloat16 err = sum_sq_lo - fputil::multiply_add(r_d, r_d, -sum_sq);
+
+    if (err > zero ) {
+      r_u |= 1;
+    } else if ((err < zero) && (r_u & 1) == 0) {
+      r_u -= 1;
+    } else if ((r_u & 0x0000'1FFF) == 0) {
+      // The rounded result is exact.
+      fputil::clear_except_if_required(FE_INEXACT);
+    }
+    return fputil::cast<bfloat16>(FloatBits(r_u).get_val());
+  }
+
+  return fputil::cast<bfloat16>(result.get_val());
+}
+
+} // namespace math
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_HYPOTBF16_H
diff --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt
index e37e22fdb58e6..3e9d41e9ed478 100644
--- a/libc/src/math/CMakeLists.txt
+++ b/libc/src/math/CMakeLists.txt
@@ -343,6 +343,7 @@ add_math_entrypoint_object(getpayloadf128)
 add_math_entrypoint_object(getpayloadbf16)
 
 add_math_entrypoint_object(hypot)
+add_math_entrypoint_object(hypotbf16)
 add_math_entrypoint_object(hypotf)
 add_math_entrypoint_object(hypotf16)
 
diff --git a/libc/src/math/generic/hypotbf16.cpp b/libc/src/math/generic/hypotbf16.cpp
index 78ecc51dfb4ce..49dd5d1f91ad2 100644
--- a/libc/src/math/generic/hypotbf16.cpp
+++ b/libc/src/math/generic/hypotbf16.cpp
@@ -1,4 +1,4 @@
-//===-- Implementation of hypotbf16 function -------------------------------===//
+//===-- Implementation of hypotbf16 function ------------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -11,8 +11,8 @@
 
 namespace LIBC_NAMESPACE_DECL {
 
-LLVM_LIBC_FUNCTION(BFloat16, hypotf, (BFloat16 x, BFloat16 y)) {
-  return math::hypotf(x, y);
+LLVM_LIBC_FUNCTION(bfloat16, hypotbf16, (bfloat16 x, bfloat16 y)) {
+  return math::hypotbf16(x, y);
 }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/hypotbf16.h b/libc/src/math/hypotbf16.h
new file mode 100644
index 0000000000000..db1365d791dba
--- /dev/null
+++ b/libc/src/math/hypotbf16.h
@@ -0,0 +1,21 @@
+//===-- Implementation header for hypotbf16 ---------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_MATH_HYPOTBF16_H
+#define LLVM_LIBC_SRC_MATH_HYPOTBF16_H
+
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+bfloat16 hypotbf16(bfloat16 x, bfloat16 y);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_HYPOTBF16_H
diff --git a/libc/test/src/math/CMakeLists.txt b/libc/test/src/math/CMakeLists.txt
index 83cf506968b9b..8f95094e36946 100644
--- a/libc/test/src/math/CMakeLists.txt
+++ b/libc/test/src/math/CMakeLists.txt
@@ -1896,6 +1896,19 @@ add_fp_unittest(
     libc.src.__support.FPUtil.fp_bits
 )
 
+add_fp_unittest(
+  hypotbf16_test
+  NEED_MPFR
+  SUITE
+    libc-math-unittests
+  SRCS
+    hypotbf16_test.cpp
+  DEPENDS
+    libc.src.math.hypotbf16
+    libc.src.__support.FPUtil.fp_bits
+    libc.src.__support.FPUtil.bfloat16
+)
+
 add_fp_unittest(
   hypotf16_test
   NEED_MPFR
diff --git a/libc/test/src/math/hypotbf16_test.cpp b/libc/test/src/math/hypotbf16_test.cpp
new file mode 100644
index 0000000000000..895e52aa51bde
--- /dev/null
+++ b/libc/test/src/math/hypotbf16_test.cpp
@@ -0,0 +1,52 @@
+//===-- Exhaustive test for hypotbf16 -------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "HypotTest.h"
+
+#include "src/math/hypotbf16.h"
+#include "src/__support/FPUtil/bfloat16.h"
+#include "test/UnitTest/FPMatcher.h"
+#include "test/UnitTest/Test.h"
+#include "utils/MPFRWrapper/MPFRUtils.h"
+
+using LlvmLibcHypotBf16Test = LIBC_NAMESPACE::testing::FPTest<bfloat16>;
+
+namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
+
+// range: [+0, inf]
+static constexpr uint16_t POS_START = 0x0000U;
+static constexpr uint16_t POS_STOP = 0x7f80U;
+
+// x+y = y+x
+TEST_F(LlvmLibcHypotBf16Test, PositiveRange){
+    for(uint16_t v1 = POS_START; v1<= POS_STOP; ++v1){
+        for(uint16_t v2 = v1; v2<=POS_STOP; ++v2){
+            bfloat16 x = FPBits(x).get_val();
+            bfloat16 y = FPBits(y).get_val();
+            mpfr::BinaryInput<bfloat16> input{x,y};
+            EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Hypot, input,LIBC_NAMESPACE::hypotbf16(x, y),0.5);
+        }
+    }
+}
+
+TEST_F(LlvmLibcHypotBf16Test, SpecialNumbers){
+    constexpr bfloat16 VAL[] = {zero,    neg_zero,   inf,
+                                   neg_inf, min_normal, max_normal};
+    for(size_t v1 = 0; v1< 6; ++v1){
+        for(uint16_t v2 = v1 ; v2< 6; ++v2){
+
+            bfloat16 x = VAL[v1];
+            bfloat16 y = VAL[v2];
+            mpfr::BinaryInput<bfloat16> input{x,y};
+            EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Hypot, input,LIBC_NAMESPACE::hypotbf16(x, y),0.5);
+        }
+    }
+}
+
+
+
diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index b58eeda678149..5438ce34de152 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -3743,6 +3743,19 @@ add_fp_unittest(
     libc.src.__support.macros.properties.architectures
 )
 
+add_fp_unittest(
+  hypotbf16_test
+  SUITE
+    libc-math-smoke-tests
+  SRCS
+    hypotbf16_test.cpp
+  HDRS
+    HypotTest.h
+  DEPENDS
+    libc.src.math.hypotbf16
+    libc.src.__support.FPUtil.bfloat16
+)
+
 add_fp_unittest(
   nanf_test
   SUITE
diff --git a/libc/test/src/math/smoke/hypotbf16_test.cpp b/libc/test/src/math/smoke/hypotbf16_test.cpp
new file mode 100644
index 0000000000000..07ae3938ccc7c
--- /dev/null
+++ b/libc/test/src/math/smoke/hypotbf16_test.cpp
@@ -0,0 +1,17 @@
+//===-- Unittests for hypotbf16 -------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "HypotTest.h"
+
+#include "src/math/hypotbf16.h"
+
+using LlvmLibcHypotbf16Test = HypotTestTemplate<bfloat16>;
+
+TEST_F(LlvmLibcHypotbf16Test, SpecialNumbers) {
+  test_special_numbers(&LIBC_NAMESPACE::hypotbf16);
+}
diff --git a/libc/utils/MPFRWrapper/MPFRUtils.cpp b/libc/utils/MPFRWrapper/MPFRUtils.cpp
index a7d307b47c3e8..c61ef66c803eb 100644
--- a/libc/utils/MPFRWrapper/MPFRUtils.cpp
+++ b/libc/utils/MPFRWrapper/MPFRUtils.cpp
@@ -408,8 +408,8 @@ template void explain_binary_operation_one_output_error(
     Operation, const BinaryInput<float16> &, float16, double, RoundingMode);
 template void
 explain_binary_operation_one_output_error(Operation, const BinaryInput<float> &,
-                                          float16, double, RoundingMode);
-template void explain_binary_operation_one_output_error(
+       explain_binary_operation_one_output_error                                   float16, double, RoundingMode);
+template void (
     Operation, const BinaryInput<double> &, float16, double, RoundingMode);
 template void explain_binary_operation_one_output_error(
     Operation, const BinaryInput<long double> &, float16, double, RoundingMode);

>From 47a7c161aa809792d351929c90afe8458e594e44 Mon Sep 17 00:00:00 2001
From: Sukumarsawant <sawantsukumar at gmail.com>
Date: Thu, 26 Feb 2026 00:13:49 +0530
Subject: [PATCH 04/19] formatted

cmake

fix: CMake

ref itself

fixed 16/32

reset MPFRUtils

header added

formatted

HypotTest.h dosent work for smoke

size_t change

MPFR

Cmake

spell

testing with lower than 2^32

formatted

true exhaustive will be moved to math/exhaustive

formatted

testing the already available FPUtil hypot

formatted

cmaked updated

test

cmake updated

typo

spell

stack
---
 libc/src/__support/math/CMakeLists.txt      |   1 +
 libc/src/__support/math/hypotbf16.h         | 102 --------------------
 libc/src/math/generic/CMakeLists.txt        |   6 +-
 libc/src/math/generic/hypotbf16.cpp         |  10 +-
 libc/test/src/math/hypotbf16_test.cpp       |  44 ++-------
 libc/test/src/math/smoke/CMakeLists.txt     |   3 +
 libc/test/src/math/smoke/hypotbf16_test.cpp |  26 ++++-
 libc/utils/MPFRWrapper/MPFRUtils.cpp        |   4 +-
 8 files changed, 45 insertions(+), 151 deletions(-)
 delete mode 100644 libc/src/__support/math/hypotbf16.h

diff --git a/libc/src/__support/math/CMakeLists.txt b/libc/src/__support/math/CMakeLists.txt
index 99bf456ff0bca..ae28a544d0bb8 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -1614,6 +1614,7 @@ add_header_library(
     libc.src.__support.FPUtil.multiply_add
     libc.src.__support.FPUtil.sqrt
     libc.src.__support.macros.optimization
+    libc.sec.__support.FPUtil.bfloat16
 )
 
 add_header_library(
diff --git a/libc/src/__support/math/hypotbf16.h b/libc/src/__support/math/hypotbf16.h
deleted file mode 100644
index 476021386b535..0000000000000
--- a/libc/src/__support/math/hypotbf16.h
+++ /dev/null
@@ -1,102 +0,0 @@
-//===-- Implementation header for hypotbf16 ---------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_HYPOTBF16_H
-#define LLVM_LIBC_SRC___SUPPORT_MATH_HYPOTBF16_H
-
-#include "src/__support/FPUtil/FEnvImpl.h"
-#include "src/__support/FPUtil/FPBits.h"
-#include "src/__support/FPUtil/cast.h"
-#include "src/__support/FPUtil/multiply_add.h"
-#include "src/__support/FPUtil/sqrt.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/optimization.h"
-#include "src/__support/macros/properties/types.h"
-#include "src/__support/FPUtil/bfloat16.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-namespace math {
-
-constexpr bfloat16 zero = bfloat16(0.0f);
-
-// For targets where conversion from float to float16 has to be
-// emulated, fputil::hypot<float16> is faster
-LIBC_INLINE bfloat16 hypotbf16(bfloat16 x, bfloat16 y) {
-  using FloatBits = fputil::FPBits<bfloat16>;
-  using FPBits = fputil::FPBits<bfloat16>;
-
-  FPBits x_abs = FPBits(x).abs();
-  FPBits y_abs = FPBits(y).abs();
-
-  bool x_abs_larger = x_abs.uintval() >= y_abs.uintval();
-
-  FPBits a_bits = x_abs_larger ? x_abs : y_abs;
-  FPBits b_bits = x_abs_larger ? y_abs : x_abs;
-
-  uint16_t a_u = a_bits.uintval();
-  uint16_t b_u = b_bits.uintval();
-
-  // Note: replacing `a_u >= FPBits::EXP_MASK` with `a_bits.is_inf_or_nan()`
-  // generates extra exponent bit masking instructions on x86-64.
-  if (LIBC_UNLIKELY(a_u >= FPBits::EXP_MASK)) {
-    // x or y is inf or nan
-    if (a_bits.is_signaling_nan() || b_bits.is_signaling_nan()) {
-      fputil::raise_except_if_required(FE_INVALID);
-      return FPBits::quiet_nan().get_val();
-    }
-    if (a_bits.is_inf() || b_bits.is_inf())
-      return FPBits::inf().get_val();
-    return a_bits.get_val();
-  }
-
-  bfloat16 af = fputil::cast<bfloat16>(a_bits.get_val());
-  bfloat16 bf = fputil::cast<bfloat16>(b_bits.get_val());
-
-  // Compiler runtime basic operations for float16 might not be correctly
-  // rounded for all rounding modes.
-  if (LIBC_UNLIKELY(a_u - b_u >=
-                    static_cast<uint16_t>((FPBits::FRACTION_LEN + 2)
-                                          << FPBits::FRACTION_LEN)))
-    return fputil::cast<bfloat16>(af + bf);
-
-  // These squares are exact.
-  bfloat16 a_sq = af * af;
-  bfloat16 sum_sq = fputil::multiply_add(bf, bf, a_sq);
-
-  FloatBits result(fputil::sqrt<bfloat16>(sum_sq));
-  uint32_t r_u = result.uintval();
-
-  // If any of the sticky bits of the result are non-zero, except the LSB, then
-  // the rounded result is correct.
-  if (LIBC_UNLIKELY(((r_u + 1) & 0x0000'0FFE) == 0)) {
-    bfloat16 r_d = result.get_val();
-
-    // Perform rounding correction.
-    bfloat16 sum_sq_lo = fputil::multiply_add(bf, bf, a_sq - sum_sq);
-    bfloat16 err = sum_sq_lo - fputil::multiply_add(r_d, r_d, -sum_sq);
-
-    if (err > zero ) {
-      r_u |= 1;
-    } else if ((err < zero) && (r_u & 1) == 0) {
-      r_u -= 1;
-    } else if ((r_u & 0x0000'1FFF) == 0) {
-      // The rounded result is exact.
-      fputil::clear_except_if_required(FE_INEXACT);
-    }
-    return fputil::cast<bfloat16>(FloatBits(r_u).get_val());
-  }
-
-  return fputil::cast<bfloat16>(result.get_val());
-}
-
-} // namespace math
-
-} // namespace LIBC_NAMESPACE_DECL
-
-#endif // LLVM_LIBC_SRC___SUPPORT_MATH_HYPOTBF16_H
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index 13a40e5c678b0..e8ab0ccf3efc8 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -3047,8 +3047,10 @@ add_entrypoint_object(
   HDRS
     ../hypotbf16.h
   DEPENDS
-    libc.src.__support.math.hypotbf16
-    libc.src.math.hypotbf16
+    libc.src.__support.FPUtil.hypot
+    libc.src.__support.FPUtil.bfloat16
+    libc.src.__support.common
+    libc.src.__support.macros.config
 )
 
 add_entrypoint_object(
diff --git a/libc/src/math/generic/hypotbf16.cpp b/libc/src/math/generic/hypotbf16.cpp
index 49dd5d1f91ad2..52c9d88f681cd 100644
--- a/libc/src/math/generic/hypotbf16.cpp
+++ b/libc/src/math/generic/hypotbf16.cpp
@@ -5,14 +5,18 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
-#include "src/math/hypotbf16.h"
-#include "src/__support/math/hypotbf16.h"
+
+#include "src/__support/FPUtil/Hypot.h"
 #include "src/__support/FPUtil/bfloat16.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+#include "src/math/hypotbf16.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
 LLVM_LIBC_FUNCTION(bfloat16, hypotbf16, (bfloat16 x, bfloat16 y)) {
-  return math::hypotbf16(x, y);
+  return fputil::hypot<bfloat16>(x, y);
 }
 
+
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/test/src/math/hypotbf16_test.cpp b/libc/test/src/math/hypotbf16_test.cpp
index 895e52aa51bde..dd36b7513d22d 100644
--- a/libc/test/src/math/hypotbf16_test.cpp
+++ b/libc/test/src/math/hypotbf16_test.cpp
@@ -1,4 +1,4 @@
-//===-- Exhaustive test for hypotbf16 -------------------------------------===//
+//===-- Exhaustive tests for hypotbf16 ------------------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -8,45 +8,15 @@
 
 #include "HypotTest.h"
 
-#include "src/math/hypotbf16.h"
 #include "src/__support/FPUtil/bfloat16.h"
-#include "test/UnitTest/FPMatcher.h"
-#include "test/UnitTest/Test.h"
-#include "utils/MPFRWrapper/MPFRUtils.h"
-
-using LlvmLibcHypotBf16Test = LIBC_NAMESPACE::testing::FPTest<bfloat16>;
-
-namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
+#include "src/math/hypotbf16.h"
 
-// range: [+0, inf]
-static constexpr uint16_t POS_START = 0x0000U;
-static constexpr uint16_t POS_STOP = 0x7f80U;
+using LlvmLibcHypotbf16Test = HypotTestTemplate<bfloat16>;
 
-// x+y = y+x
-TEST_F(LlvmLibcHypotBf16Test, PositiveRange){
-    for(uint16_t v1 = POS_START; v1<= POS_STOP; ++v1){
-        for(uint16_t v2 = v1; v2<=POS_STOP; ++v2){
-            bfloat16 x = FPBits(x).get_val();
-            bfloat16 y = FPBits(y).get_val();
-            mpfr::BinaryInput<bfloat16> input{x,y};
-            EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Hypot, input,LIBC_NAMESPACE::hypotbf16(x, y),0.5);
-        }
-    }
+TEST_F(LlvmLibcHypotbf16Test, SubnormalRange) {
+  test_subnormal_range(&LIBC_NAMESPACE::hypotbf16);
 }
 
-TEST_F(LlvmLibcHypotBf16Test, SpecialNumbers){
-    constexpr bfloat16 VAL[] = {zero,    neg_zero,   inf,
-                                   neg_inf, min_normal, max_normal};
-    for(size_t v1 = 0; v1< 6; ++v1){
-        for(uint16_t v2 = v1 ; v2< 6; ++v2){
-
-            bfloat16 x = VAL[v1];
-            bfloat16 y = VAL[v2];
-            mpfr::BinaryInput<bfloat16> input{x,y};
-            EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Hypot, input,LIBC_NAMESPACE::hypotbf16(x, y),0.5);
-        }
-    }
+TEST_F(LlvmLibcHypotbf16Test, NormalRange) {
+  test_normal_range(&LIBC_NAMESPACE::hypotbf16);
 }
-
-
-
diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index 5438ce34de152..83a4e337c514b 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -3754,6 +3754,9 @@ add_fp_unittest(
   DEPENDS
     libc.src.math.hypotbf16
     libc.src.__support.FPUtil.bfloat16
+    libc.test.UnitTest.FPMatcher
+    libc.test.UnitTest.Test
+    libc.utils.MPFRWrapper.MPFRUtils
 )
 
 add_fp_unittest(
diff --git a/libc/test/src/math/smoke/hypotbf16_test.cpp b/libc/test/src/math/smoke/hypotbf16_test.cpp
index 07ae3938ccc7c..a0935a58d1f38 100644
--- a/libc/test/src/math/smoke/hypotbf16_test.cpp
+++ b/libc/test/src/math/smoke/hypotbf16_test.cpp
@@ -6,12 +6,28 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "HypotTest.h"
-
+#include "src/__support/FPUtil/bfloat16.h"
 #include "src/math/hypotbf16.h"
+#include "test/UnitTest/FPMatcher.h"
+#include "test/UnitTest/Test.h"
+#include "utils/MPFRWrapper/MPFRUtils.h"
+
+using LlvmLibcHypotBf16Test = LIBC_NAMESPACE::testing::FPTest<bfloat16>;
 
-using LlvmLibcHypotbf16Test = HypotTestTemplate<bfloat16>;
+namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
 
-TEST_F(LlvmLibcHypotbf16Test, SpecialNumbers) {
-  test_special_numbers(&LIBC_NAMESPACE::hypotbf16);
+TEST_F(LlvmLibcHypotBf16Test, SpecialNumbers) {
+  constexpr bfloat16 VAL[] = {zero,    neg_zero,   inf,
+                              neg_inf, min_normal, max_normal};
+  for (size_t v1 = 0; v1 < 6; ++v1) {
+    for (size_t v2 = v1; v2 < 6; ++v2) {
+
+      bfloat16 x = VAL[v1];
+      bfloat16 y = VAL[v2];
+      mpfr::BinaryInput<bfloat16> input{x, y};
+      EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Hypot, input,
+                                     LIBC_NAMESPACE::hypotbf16(x, y), 0.5);
+    }
+  }
 }
+
diff --git a/libc/utils/MPFRWrapper/MPFRUtils.cpp b/libc/utils/MPFRWrapper/MPFRUtils.cpp
index c61ef66c803eb..a7d307b47c3e8 100644
--- a/libc/utils/MPFRWrapper/MPFRUtils.cpp
+++ b/libc/utils/MPFRWrapper/MPFRUtils.cpp
@@ -408,8 +408,8 @@ template void explain_binary_operation_one_output_error(
     Operation, const BinaryInput<float16> &, float16, double, RoundingMode);
 template void
 explain_binary_operation_one_output_error(Operation, const BinaryInput<float> &,
-       explain_binary_operation_one_output_error                                   float16, double, RoundingMode);
-template void (
+                                          float16, double, RoundingMode);
+template void explain_binary_operation_one_output_error(
     Operation, const BinaryInput<double> &, float16, double, RoundingMode);
 template void explain_binary_operation_one_output_error(
     Operation, const BinaryInput<long double> &, float16, double, RoundingMode);

>From bdd24e022f5a384e316fa42e86153dbdb8829239 Mon Sep 17 00:00:00 2001
From: Sukumarsawant <sawantsukumar at gmail.com>
Date: Thu, 26 Feb 2026 11:46:36 +0530
Subject: [PATCH 05/19] added true exhaustive test

---
 libc/test/src/math/exhaustive/CMakeLists.txt  | 1452 +++++++++--------
 .../src/math/exhaustive/hypotbf16_test.cpp    |  108 ++
 libc/test/src/math/hypotbf16_test.cpp         |    2 +-
 3 files changed, 844 insertions(+), 718 deletions(-)
 create mode 100644 libc/test/src/math/exhaustive/hypotbf16_test.cpp

diff --git a/libc/test/src/math/exhaustive/CMakeLists.txt b/libc/test/src/math/exhaustive/CMakeLists.txt
index 9ca4f93e6c411..3fcd6f61a7653 100644
--- a/libc/test/src/math/exhaustive/CMakeLists.txt
+++ b/libc/test/src/math/exhaustive/CMakeLists.txt
@@ -1,717 +1,735 @@
-add_libc_exhaustive_testsuite(libc_math_exhaustive_tests)
-
-add_header_library(
-  exhaustive_test
-  HDRS
-    exhaustive_test.h
-  DEPENDS
-    libc.src.__support.CPP.type_traits
-    libc.src.__support.FPUtil.fp_bits
-    libc.src.__support.macros.properties.types
-)
-
-add_fp_unittest(
-  sqrtf_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    sqrtf_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.sqrtf
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  rsqrtf_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    rsqrtf_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.rsqrtf
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  sinf_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    sinf_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.sinf
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  sinf_float_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    sinf_float_test.cpp
-  LINK_LIBRARIES
-    -lpthread
-  DEPENDS
-    .exhaustive_test
-    libc.src.__support.math.sincosf_utils
-)
-
-add_fp_unittest(
-  sinpif_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    sinpif_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.sinpif
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  cosf_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    cosf_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.cosf
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  cosf_float_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    cosf_float_test.cpp
-  LINK_LIBRARIES
-    -lpthread
-  DEPENDS
-    .exhaustive_test
-    libc.src.__support.math.sincosf_utils
-)
-
-add_fp_unittest(
-  cospif_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    cospif_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.cospif
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  sincosf_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    sincosf_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.sincosf
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  tanf_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    tanf_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.tanf
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  tanpif_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    tanpif_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.tanpif
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  erff_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    erff_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.erff
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  expf_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    expf_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.expf
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  exp2f_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    exp2f_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.exp2f
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  exp2m1f_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    exp2m1f_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.exp2m1f
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  exp10f_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    exp10f_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.exp10f
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  exp10m1f_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    exp10m1f_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.exp10m1f
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  expm1f_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    expm1f_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.expm1f
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  logf_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    logf_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.logf
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  log10f_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    log10f_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.log10f
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  log1pf_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    log1pf_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.log1pf
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  log2f_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    log2f_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.log2f
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  hypotf_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    hypotf_test.cpp
-  COMPILE_OPTIONS
-    ${libc_opt_high_flag}
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.hypotf
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  hypotf16_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    hypotf16_test.cpp
-  COMPILE_OPTIONS
-    ${libc_opt_high_flag}
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.hypotf16
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  fmod_generic_impl_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    fmod_generic_impl_test.cpp
-  DEPENDS
-    libc.src.__support.FPUtil.fp_bits
-    libc.src.__support.FPUtil.manipulation_functions
-    libc.src.__support.FPUtil.generic.fmod
-)
-
-add_fp_unittest(
-  fmodf16_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    fmodf16_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.fmodf16
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  fmodbf16_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    fmodbf16_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.fmodbf16
-    libc.src.__support.FPUtil.bfloat16
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  coshf_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    coshf_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.coshf
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  sinhf_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    sinhf_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.sinhf
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  tanhf_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    tanhf_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.tanhf
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  acoshf_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    acoshf_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.acoshf
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  asinhf_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    asinhf_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.asinhf
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  atanhf_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    atanhf_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.atanhf
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  atanf_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    atanf_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.atanf
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  atanf_float_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    atanf_float_test.cpp
-  LINK_LIBRARIES
-    -lpthread
-  DEPENDS
-    .exhaustive_test
-    libc.src.__support.math.atanf
-)
-
-add_fp_unittest(
-  asinf_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    asinf_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.asinf
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  acosf_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    acosf_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.acosf
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  f16sqrtf_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    f16sqrtf_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.f16sqrtf
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  cbrtf_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    cbrtf_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.cbrtf
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  bfloat16_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    bfloat16_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.__support.FPUtil.bfloat16
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  bfloat16_add_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    bfloat16_add_test.cpp
-  COMPILE_OPTIONS
-    ${libc_opt_high_flag}
-  DEPENDS
-    .exhaustive_test
-    libc.src.__support.FPUtil.bfloat16
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  bfloat16_div_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    bfloat16_div_test.cpp
-  COMPILE_OPTIONS
-    ${libc_opt_high_flag}
-  DEPENDS
-    .exhaustive_test
-    libc.src.__support.FPUtil.bfloat16
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  bfloat16_mul_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    bfloat16_mul_test.cpp
-  COMPILE_OPTIONS
-    ${libc_opt_high_flag}
-  DEPENDS
-    .exhaustive_test
-    libc.src.__support.FPUtil.bfloat16
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  bfloat16_sub_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    bfloat16_sub_test.cpp
-  COMPILE_OPTIONS
-    ${libc_opt_high_flag}
-  DEPENDS
-    .exhaustive_test
-    libc.src.__support.FPUtil.bfloat16
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
+add_libc_exhaustive_testsuite(libc_math_exhaustive_tests)
+
+add_header_library(
+  exhaustive_test
+  HDRS
+    exhaustive_test.h
+  DEPENDS
+    libc.src.__support.CPP.type_traits
+    libc.src.__support.FPUtil.fp_bits
+    libc.src.__support.macros.properties.types
+)
+
+add_fp_unittest(
+  sqrtf_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    sqrtf_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.sqrtf
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  rsqrtf_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    rsqrtf_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.rsqrtf
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  sinf_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    sinf_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.sinf
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  sinf_float_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    sinf_float_test.cpp
+  LINK_LIBRARIES
+    -lpthread
+  DEPENDS
+    .exhaustive_test
+    libc.src.__support.math.sincosf_utils
+)
+
+add_fp_unittest(
+  sinpif_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    sinpif_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.sinpif
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  cosf_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    cosf_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.cosf
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  cosf_float_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    cosf_float_test.cpp
+  LINK_LIBRARIES
+    -lpthread
+  DEPENDS
+    .exhaustive_test
+    libc.src.__support.math.sincosf_utils
+)
+
+add_fp_unittest(
+  cospif_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    cospif_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.cospif
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  sincosf_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    sincosf_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.sincosf
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  tanf_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    tanf_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.tanf
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  tanpif_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    tanpif_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.tanpif
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  erff_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    erff_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.erff
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  expf_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    expf_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.expf
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  exp2f_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    exp2f_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.exp2f
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  exp2m1f_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    exp2m1f_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.exp2m1f
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  exp10f_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    exp10f_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.exp10f
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  exp10m1f_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    exp10m1f_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.exp10m1f
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  expm1f_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    expm1f_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.expm1f
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  logf_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    logf_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.logf
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  log10f_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    log10f_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.log10f
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  log1pf_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    log1pf_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.log1pf
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  log2f_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    log2f_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.log2f
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  hypotbf16_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    hypotbf16_test.cpp
+  COMPILE_OPTIONS
+    ${libc_opt_high_flag}
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.hypotbf16
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  hypotf_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    hypotf_test.cpp
+  COMPILE_OPTIONS
+    ${libc_opt_high_flag}
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.hypotf
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  hypotf16_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    hypotf16_test.cpp
+  COMPILE_OPTIONS
+    ${libc_opt_high_flag}
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.hypotf16
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  fmod_generic_impl_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    fmod_generic_impl_test.cpp
+  DEPENDS
+    libc.src.__support.FPUtil.fp_bits
+    libc.src.__support.FPUtil.manipulation_functions
+    libc.src.__support.FPUtil.generic.fmod
+)
+
+add_fp_unittest(
+  fmodf16_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    fmodf16_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.fmodf16
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  fmodbf16_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    fmodbf16_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.fmodbf16
+    libc.src.__support.FPUtil.bfloat16
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  coshf_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    coshf_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.coshf
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  sinhf_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    sinhf_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.sinhf
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  tanhf_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    tanhf_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.tanhf
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  acoshf_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    acoshf_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.acoshf
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  asinhf_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    asinhf_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.asinhf
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  atanhf_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    atanhf_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.atanhf
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  atanf_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    atanf_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.atanf
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  atanf_float_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    atanf_float_test.cpp
+  LINK_LIBRARIES
+    -lpthread
+  DEPENDS
+    .exhaustive_test
+    libc.src.__support.math.atanf
+)
+
+add_fp_unittest(
+  asinf_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    asinf_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.asinf
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  acosf_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    acosf_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.acosf
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  f16sqrtf_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    f16sqrtf_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.f16sqrtf
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  cbrtf_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    cbrtf_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.cbrtf
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  bfloat16_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    bfloat16_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.__support.FPUtil.bfloat16
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  bfloat16_add_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    bfloat16_add_test.cpp
+  COMPILE_OPTIONS
+    ${libc_opt_high_flag}
+  DEPENDS
+    .exhaustive_test
+    libc.src.__support.FPUtil.bfloat16
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  bfloat16_div_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    bfloat16_div_test.cpp
+  COMPILE_OPTIONS
+    ${libc_opt_high_flag}
+  DEPENDS
+    .exhaustive_test
+    libc.src.__support.FPUtil.bfloat16
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  bfloat16_mul_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    bfloat16_mul_test.cpp
+  COMPILE_OPTIONS
+    ${libc_opt_high_flag}
+  DEPENDS
+    .exhaustive_test
+    libc.src.__support.FPUtil.bfloat16
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  bfloat16_sub_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    bfloat16_sub_test.cpp
+  COMPILE_OPTIONS
+    ${libc_opt_high_flag}
+  DEPENDS
+    .exhaustive_test
+    libc.src.__support.FPUtil.bfloat16
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
diff --git a/libc/test/src/math/exhaustive/hypotbf16_test.cpp b/libc/test/src/math/exhaustive/hypotbf16_test.cpp
new file mode 100644
index 0000000000000..cfc34c39099ce
--- /dev/null
+++ b/libc/test/src/math/exhaustive/hypotbf16_test.cpp
@@ -0,0 +1,108 @@
+//===-- Exhaustive test for hypotbf16 -------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/__support/FPUtil/bfloat16.h"
+#include "src/math/hypotbf16.h"
+#include "test/UnitTest/FPMatcher.h"
+#include "test/UnitTest/Test.h"
+#include "utils/MPFRWrapper/MPFRUtils.h"
+
+using LlvmLibcHypotBf16Test = LIBC_NAMESPACE::testing::FPTest<bfloat16>;
+
+namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
+
+// Normal range: [+0, +int]
+static constexpr uint16_t POS_START = 0x0000U;
+static constexpr uint16_t POS_STOP = 0x7f80U;
+
+// Normal range: [-0, -int]
+static constexpr uint16_t NEG_START = 0x8000U;
+static constexpr uint16_t NEG_STOP = 0xff80U;
+
+// Subnormal range (positive)
+static constexpr uint16_t SUBNORM_POS_START = 0x0001U;
+static constexpr uint16_t SUBNORM_POS_STOP = 0x007FU;
+
+// Subnormal range (negative)
+static constexpr uint16_t SUBNORM_NEG_START = 0x8001U;
+static constexpr uint16_t SUBNORM_NEG_STOP = 0x807FU;
+
+TEST_F(LlvmLibcHypotBf16Test,NormalPositiveRange){
+    for (uint16_t v1 = POS_START; v1 <= POS_STOP; v1++) {
+    for (uint16_t v2 = v1; v2 <= POS_STOP; v2++) {
+
+      bfloat16 x = FPBits(v1).get_val();
+      bfloat16 y = FPBits(v2).get_val();
+        mpfr::BinaryInput<bfloat16> input{x, y};
+
+        EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Hypot, input,
+                                       LIBC_NAMESPACE::hypotbf16(x, y), 0.5);
+      
+    }
+  }
+}
+
+TEST_F(LlvmLibcHypotBf16Test,NormalNegativeRange){
+    for (uint16_t v1 = NEG_START; v1 <= NEG_STOP; v1++) {
+    for (uint16_t v2 = v1; v2 <= NEG_STOP; v2++) {
+
+      bfloat16 x = FPBits(v1).get_val();
+      bfloat16 y = FPBits(v2).get_val();
+        mpfr::BinaryInput<bfloat16> input{x, y};
+
+        EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Hypot, input,
+                                       LIBC_NAMESPACE::hypotbf16(x, y), 0.5);
+      
+    }
+  }
+}
+
+TEST_F(LlvmLibcHypotBf16Test, SubnormalNegativeRange) {
+  for (uint16_t v1 = SUBNORM_NEG_START; v1 <= SUBNORM_NEG_STOP; v1++) {
+    for (uint16_t v2 = v1; v2 <= SUBNORM_NEG_STOP; v2++) {
+
+      bfloat16 x = FPBits(v1).get_val();
+      bfloat16 y = FPBits(v2).get_val();
+        mpfr::BinaryInput<bfloat16> input{x, y};
+
+        EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Hypot, input,
+                                       LIBC_NAMESPACE::hypotbf16(x, y), 0.5);
+      
+    }
+  }
+}
+
+TEST_F(LlvmLibcHypotBf16Test, SubnormalPositiveRange) {
+  for (uint16_t v1 = SUBNORM_POS_START; v1 <= SUBNORM_POS_STOP; v1++) {
+    for (uint16_t v2 = v1; v2 <= SUBNORM_POS_STOP; v2++) {
+
+      bfloat16 x = FPBits(v1).get_val();
+      bfloat16 y = FPBits(v2).get_val();
+        mpfr::BinaryInput<bfloat16> input{x, y};
+
+        EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Hypot, input,
+                                       LIBC_NAMESPACE::hypotbf16(x, y), 0.5);
+      
+    }
+  }
+}
+TEST_F(LlvmLibcHypotBf16Test, SpecialNumbers) {
+  constexpr bfloat16 VALUES[] = {zero,    neg_zero,   inf,
+                                 neg_inf, min_normal, max_normal};
+  for (size_t i = 0; i < 6; ++i) {
+    for (size_t j = i; j < 6; ++j) { 
+      bfloat16 x = VALUES[i];
+      bfloat16 y = VALUES[j];
+        mpfr::BinaryInput<bfloat16> input{x, y};
+
+        EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Hypot, input,
+                                       LIBC_NAMESPACE::hypotbf16(x, y), 0.5);
+      
+    }
+  }
+}
\ No newline at end of file
diff --git a/libc/test/src/math/hypotbf16_test.cpp b/libc/test/src/math/hypotbf16_test.cpp
index dd36b7513d22d..a757ff751ba77 100644
--- a/libc/test/src/math/hypotbf16_test.cpp
+++ b/libc/test/src/math/hypotbf16_test.cpp
@@ -1,4 +1,4 @@
-//===-- Exhaustive tests for hypotbf16 ------------------------------------===//
+//===-- Unittests tests for hypotbf16 ------------------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.

>From 0c52bc5f4873b06442202d0b3b2b097d3fa47ce4 Mon Sep 17 00:00:00 2001
From: Sukumarsawant <sawantsukumar at gmail.com>
Date: Thu, 26 Feb 2026 12:07:45 +0530
Subject: [PATCH 06/19] reverted additional line + checking CRLF errors

---
 libc/src/__support/math/CMakeLists.txt           | 1 -
 libc/test/src/math/exhaustive/hypotbf16_test.cpp | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/libc/src/__support/math/CMakeLists.txt b/libc/src/__support/math/CMakeLists.txt
index ae28a544d0bb8..99bf456ff0bca 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -1614,7 +1614,6 @@ add_header_library(
     libc.src.__support.FPUtil.multiply_add
     libc.src.__support.FPUtil.sqrt
     libc.src.__support.macros.optimization
-    libc.sec.__support.FPUtil.bfloat16
 )
 
 add_header_library(
diff --git a/libc/test/src/math/exhaustive/hypotbf16_test.cpp b/libc/test/src/math/exhaustive/hypotbf16_test.cpp
index cfc34c39099ce..8db2d52084df3 100644
--- a/libc/test/src/math/exhaustive/hypotbf16_test.cpp
+++ b/libc/test/src/math/exhaustive/hypotbf16_test.cpp
@@ -105,4 +105,4 @@ TEST_F(LlvmLibcHypotBf16Test, SpecialNumbers) {
       
     }
   }
-}
\ No newline at end of file
+}

>From 6aaf656f45b830f7c87157c37007ae678f807fbd Mon Sep 17 00:00:00 2001
From: Sukumarsawant <sawantsukumar at gmail.com>
Date: Thu, 26 Feb 2026 12:13:12 +0530
Subject: [PATCH 07/19] test

---
 libc/test/src/math/exhaustive/CMakeLists.txt | 1471 +++++++++---------
 1 file changed, 736 insertions(+), 735 deletions(-)

diff --git a/libc/test/src/math/exhaustive/CMakeLists.txt b/libc/test/src/math/exhaustive/CMakeLists.txt
index 3fcd6f61a7653..037a69de4948f 100644
--- a/libc/test/src/math/exhaustive/CMakeLists.txt
+++ b/libc/test/src/math/exhaustive/CMakeLists.txt
@@ -1,735 +1,736 @@
-add_libc_exhaustive_testsuite(libc_math_exhaustive_tests)
-
-add_header_library(
-  exhaustive_test
-  HDRS
-    exhaustive_test.h
-  DEPENDS
-    libc.src.__support.CPP.type_traits
-    libc.src.__support.FPUtil.fp_bits
-    libc.src.__support.macros.properties.types
-)
-
-add_fp_unittest(
-  sqrtf_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    sqrtf_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.sqrtf
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  rsqrtf_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    rsqrtf_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.rsqrtf
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  sinf_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    sinf_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.sinf
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  sinf_float_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    sinf_float_test.cpp
-  LINK_LIBRARIES
-    -lpthread
-  DEPENDS
-    .exhaustive_test
-    libc.src.__support.math.sincosf_utils
-)
-
-add_fp_unittest(
-  sinpif_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    sinpif_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.sinpif
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  cosf_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    cosf_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.cosf
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  cosf_float_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    cosf_float_test.cpp
-  LINK_LIBRARIES
-    -lpthread
-  DEPENDS
-    .exhaustive_test
-    libc.src.__support.math.sincosf_utils
-)
-
-add_fp_unittest(
-  cospif_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    cospif_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.cospif
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  sincosf_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    sincosf_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.sincosf
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  tanf_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    tanf_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.tanf
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  tanpif_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    tanpif_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.tanpif
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  erff_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    erff_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.erff
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  expf_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    expf_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.expf
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  exp2f_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    exp2f_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.exp2f
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  exp2m1f_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    exp2m1f_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.exp2m1f
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  exp10f_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    exp10f_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.exp10f
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  exp10m1f_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    exp10m1f_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.exp10m1f
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  expm1f_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    expm1f_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.expm1f
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  logf_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    logf_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.logf
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  log10f_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    log10f_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.log10f
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  log1pf_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    log1pf_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.log1pf
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  log2f_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    log2f_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.log2f
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  hypotbf16_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    hypotbf16_test.cpp
-  COMPILE_OPTIONS
-    ${libc_opt_high_flag}
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.hypotbf16
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  hypotf_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    hypotf_test.cpp
-  COMPILE_OPTIONS
-    ${libc_opt_high_flag}
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.hypotf
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  hypotf16_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    hypotf16_test.cpp
-  COMPILE_OPTIONS
-    ${libc_opt_high_flag}
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.hypotf16
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  fmod_generic_impl_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    fmod_generic_impl_test.cpp
-  DEPENDS
-    libc.src.__support.FPUtil.fp_bits
-    libc.src.__support.FPUtil.manipulation_functions
-    libc.src.__support.FPUtil.generic.fmod
-)
-
-add_fp_unittest(
-  fmodf16_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    fmodf16_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.fmodf16
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  fmodbf16_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    fmodbf16_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.fmodbf16
-    libc.src.__support.FPUtil.bfloat16
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  coshf_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    coshf_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.coshf
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  sinhf_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    sinhf_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.sinhf
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  tanhf_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    tanhf_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.tanhf
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  acoshf_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    acoshf_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.acoshf
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  asinhf_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    asinhf_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.asinhf
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  atanhf_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    atanhf_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.atanhf
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  atanf_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    atanf_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.atanf
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  atanf_float_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    atanf_float_test.cpp
-  LINK_LIBRARIES
-    -lpthread
-  DEPENDS
-    .exhaustive_test
-    libc.src.__support.math.atanf
-)
-
-add_fp_unittest(
-  asinf_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    asinf_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.asinf
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  acosf_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    acosf_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.acosf
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  f16sqrtf_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    f16sqrtf_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.f16sqrtf
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  cbrtf_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    cbrtf_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.math.cbrtf
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  bfloat16_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    bfloat16_test.cpp
-  DEPENDS
-    .exhaustive_test
-    libc.src.__support.FPUtil.bfloat16
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  bfloat16_add_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    bfloat16_add_test.cpp
-  COMPILE_OPTIONS
-    ${libc_opt_high_flag}
-  DEPENDS
-    .exhaustive_test
-    libc.src.__support.FPUtil.bfloat16
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  bfloat16_div_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    bfloat16_div_test.cpp
-  COMPILE_OPTIONS
-    ${libc_opt_high_flag}
-  DEPENDS
-    .exhaustive_test
-    libc.src.__support.FPUtil.bfloat16
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  bfloat16_mul_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    bfloat16_mul_test.cpp
-  COMPILE_OPTIONS
-    ${libc_opt_high_flag}
-  DEPENDS
-    .exhaustive_test
-    libc.src.__support.FPUtil.bfloat16
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
-
-add_fp_unittest(
-  bfloat16_sub_test
-  NO_RUN_POSTBUILD
-  NEED_MPFR
-  SUITE
-    libc_math_exhaustive_tests
-  SRCS
-    bfloat16_sub_test.cpp
-  COMPILE_OPTIONS
-    ${libc_opt_high_flag}
-  DEPENDS
-    .exhaustive_test
-    libc.src.__support.FPUtil.bfloat16
-    libc.src.__support.FPUtil.fp_bits
-  LINK_LIBRARIES
-    -lpthread
-)
+add_libc_exhaustive_testsuite(libc_math_exhaustive_tests)
+
+add_header_library(
+  exhaustive_test
+  HDRS
+    exhaustive_test.h
+  DEPENDS
+    libc.src.__support.CPP.type_traits
+    libc.src.__support.FPUtil.fp_bits
+    libc.src.__support.macros.properties.types
+)
+
+add_fp_unittest(
+  sqrtf_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    sqrtf_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.sqrtf
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  rsqrtf_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    rsqrtf_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.rsqrtf
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  sinf_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    sinf_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.sinf
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  sinf_float_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    sinf_float_test.cpp
+  LINK_LIBRARIES
+    -lpthread
+  DEPENDS
+    .exhaustive_test
+    libc.src.__support.math.sincosf_utils
+)
+
+add_fp_unittest(
+  sinpif_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    sinpif_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.sinpif
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  cosf_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    cosf_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.cosf
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  cosf_float_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    cosf_float_test.cpp
+  LINK_LIBRARIES
+    -lpthread
+  DEPENDS
+    .exhaustive_test
+    libc.src.__support.math.sincosf_utils
+)
+
+add_fp_unittest(
+  cospif_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    cospif_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.cospif
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  sincosf_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    sincosf_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.sincosf
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  tanf_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    tanf_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.tanf
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  tanpif_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    tanpif_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.tanpif
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  erff_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    erff_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.erff
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  expf_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    expf_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.expf
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  exp2f_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    exp2f_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.exp2f
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  exp2m1f_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    exp2m1f_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.exp2m1f
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  exp10f_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    exp10f_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.exp10f
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  exp10m1f_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    exp10m1f_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.exp10m1f
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  expm1f_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    expm1f_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.expm1f
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  logf_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    logf_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.logf
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  log10f_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    log10f_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.log10f
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  log1pf_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    log1pf_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.log1pf
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  log2f_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    log2f_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.log2f
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+
+add_fp_unittest(
+  hypotbf16_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    hypotbf16_test.cpp
+  COMPILE_OPTIONS
+    ${libc_opt_high_flag}
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.hypotbf16
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  hypotf_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    hypotf_test.cpp
+  COMPILE_OPTIONS
+    ${libc_opt_high_flag}
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.hypotf
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  hypotf16_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    hypotf16_test.cpp
+  COMPILE_OPTIONS
+    ${libc_opt_high_flag}
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.hypotf16
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  fmod_generic_impl_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    fmod_generic_impl_test.cpp
+  DEPENDS
+    libc.src.__support.FPUtil.fp_bits
+    libc.src.__support.FPUtil.manipulation_functions
+    libc.src.__support.FPUtil.generic.fmod
+)
+
+add_fp_unittest(
+  fmodf16_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    fmodf16_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.fmodf16
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  fmodbf16_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    fmodbf16_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.fmodbf16
+    libc.src.__support.FPUtil.bfloat16
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  coshf_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    coshf_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.coshf
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  sinhf_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    sinhf_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.sinhf
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  tanhf_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    tanhf_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.tanhf
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  acoshf_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    acoshf_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.acoshf
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  asinhf_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    asinhf_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.asinhf
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  atanhf_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    atanhf_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.atanhf
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  atanf_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    atanf_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.atanf
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  atanf_float_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    atanf_float_test.cpp
+  LINK_LIBRARIES
+    -lpthread
+  DEPENDS
+    .exhaustive_test
+    libc.src.__support.math.atanf
+)
+
+add_fp_unittest(
+  asinf_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    asinf_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.asinf
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  acosf_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    acosf_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.acosf
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  f16sqrtf_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    f16sqrtf_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.f16sqrtf
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  cbrtf_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    cbrtf_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.math.cbrtf
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  bfloat16_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    bfloat16_test.cpp
+  DEPENDS
+    .exhaustive_test
+    libc.src.__support.FPUtil.bfloat16
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  bfloat16_add_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    bfloat16_add_test.cpp
+  COMPILE_OPTIONS
+    ${libc_opt_high_flag}
+  DEPENDS
+    .exhaustive_test
+    libc.src.__support.FPUtil.bfloat16
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  bfloat16_div_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    bfloat16_div_test.cpp
+  COMPILE_OPTIONS
+    ${libc_opt_high_flag}
+  DEPENDS
+    .exhaustive_test
+    libc.src.__support.FPUtil.bfloat16
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  bfloat16_mul_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    bfloat16_mul_test.cpp
+  COMPILE_OPTIONS
+    ${libc_opt_high_flag}
+  DEPENDS
+    .exhaustive_test
+    libc.src.__support.FPUtil.bfloat16
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)
+
+add_fp_unittest(
+  bfloat16_sub_test
+  NO_RUN_POSTBUILD
+  NEED_MPFR
+  SUITE
+    libc_math_exhaustive_tests
+  SRCS
+    bfloat16_sub_test.cpp
+  COMPILE_OPTIONS
+    ${libc_opt_high_flag}
+  DEPENDS
+    .exhaustive_test
+    libc.src.__support.FPUtil.bfloat16
+    libc.src.__support.FPUtil.fp_bits
+  LINK_LIBRARIES
+    -lpthread
+)

>From ebc2eb63560b0c35706cce4fdd705e6780e26664 Mon Sep 17 00:00:00 2001
From: Sukumarsawant <sawantsukumar at gmail.com>
Date: Thu, 26 Feb 2026 12:17:38 +0530
Subject: [PATCH 08/19] test

---
 libc/test/src/math/exhaustive/hypotbf16_test.cpp | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/libc/test/src/math/exhaustive/hypotbf16_test.cpp b/libc/test/src/math/exhaustive/hypotbf16_test.cpp
index 8db2d52084df3..7d866b9474f9a 100644
--- a/libc/test/src/math/exhaustive/hypotbf16_test.cpp
+++ b/libc/test/src/math/exhaustive/hypotbf16_test.cpp
@@ -42,7 +42,7 @@ TEST_F(LlvmLibcHypotBf16Test,NormalPositiveRange){
 
         EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Hypot, input,
                                        LIBC_NAMESPACE::hypotbf16(x, y), 0.5);
-      
+
     }
   }
 }
@@ -57,7 +57,7 @@ TEST_F(LlvmLibcHypotBf16Test,NormalNegativeRange){
 
         EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Hypot, input,
                                        LIBC_NAMESPACE::hypotbf16(x, y), 0.5);
-      
+
     }
   }
 }
@@ -72,7 +72,7 @@ TEST_F(LlvmLibcHypotBf16Test, SubnormalNegativeRange) {
 
         EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Hypot, input,
                                        LIBC_NAMESPACE::hypotbf16(x, y), 0.5);
-      
+
     }
   }
 }
@@ -87,7 +87,7 @@ TEST_F(LlvmLibcHypotBf16Test, SubnormalPositiveRange) {
 
         EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Hypot, input,
                                        LIBC_NAMESPACE::hypotbf16(x, y), 0.5);
-      
+
     }
   }
 }
@@ -95,14 +95,14 @@ TEST_F(LlvmLibcHypotBf16Test, SpecialNumbers) {
   constexpr bfloat16 VALUES[] = {zero,    neg_zero,   inf,
                                  neg_inf, min_normal, max_normal};
   for (size_t i = 0; i < 6; ++i) {
-    for (size_t j = i; j < 6; ++j) { 
+    for (size_t j = i; j < 6; ++j) {
       bfloat16 x = VALUES[i];
       bfloat16 y = VALUES[j];
         mpfr::BinaryInput<bfloat16> input{x, y};
 
         EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Hypot, input,
                                        LIBC_NAMESPACE::hypotbf16(x, y), 0.5);
-      
+
     }
   }
 }

>From 18852b88b0a1259abf8825c56b881e5c7dbe037c Mon Sep 17 00:00:00 2001
From: Sukumarsawant <sawantsukumar at gmail.com>
Date: Thu, 26 Feb 2026 12:19:39 +0530
Subject: [PATCH 09/19] formatted

---
 libc/test/src/math/exhaustive/hypotbf16_test.cpp | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/libc/test/src/math/exhaustive/hypotbf16_test.cpp b/libc/test/src/math/exhaustive/hypotbf16_test.cpp
index 7d866b9474f9a..4001d20f5b843 100644
--- a/libc/test/src/math/exhaustive/hypotbf16_test.cpp
+++ b/libc/test/src/math/exhaustive/hypotbf16_test.cpp
@@ -42,7 +42,6 @@ TEST_F(LlvmLibcHypotBf16Test,NormalPositiveRange){
 
         EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Hypot, input,
                                        LIBC_NAMESPACE::hypotbf16(x, y), 0.5);
-
     }
   }
 }
@@ -57,7 +56,6 @@ TEST_F(LlvmLibcHypotBf16Test,NormalNegativeRange){
 
         EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Hypot, input,
                                        LIBC_NAMESPACE::hypotbf16(x, y), 0.5);
-
     }
   }
 }
@@ -72,7 +70,6 @@ TEST_F(LlvmLibcHypotBf16Test, SubnormalNegativeRange) {
 
         EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Hypot, input,
                                        LIBC_NAMESPACE::hypotbf16(x, y), 0.5);
-
     }
   }
 }
@@ -87,7 +84,6 @@ TEST_F(LlvmLibcHypotBf16Test, SubnormalPositiveRange) {
 
         EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Hypot, input,
                                        LIBC_NAMESPACE::hypotbf16(x, y), 0.5);
-
     }
   }
 }
@@ -102,7 +98,6 @@ TEST_F(LlvmLibcHypotBf16Test, SpecialNumbers) {
 
         EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Hypot, input,
                                        LIBC_NAMESPACE::hypotbf16(x, y), 0.5);
-
     }
   }
 }

>From 326bda4f4a50c668967eb76a004afa947f97b986 Mon Sep 17 00:00:00 2001
From: Sukumarsawant <sawantsukumar at gmail.com>
Date: Thu, 26 Feb 2026 12:30:55 +0530
Subject: [PATCH 10/19] clang-format errors

---
 libc/src/math/generic/hypotbf16.cpp           |  3 +-
 .../src/math/exhaustive/hypotbf16_test.cpp    | 34 +++++++++----------
 libc/test/src/math/smoke/hypotbf16_test.cpp   |  1 -
 3 files changed, 18 insertions(+), 20 deletions(-)

diff --git a/libc/src/math/generic/hypotbf16.cpp b/libc/src/math/generic/hypotbf16.cpp
index 52c9d88f681cd..6852d6fa77035 100644
--- a/libc/src/math/generic/hypotbf16.cpp
+++ b/libc/src/math/generic/hypotbf16.cpp
@@ -6,11 +6,11 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "src/math/hypotbf16.h"
 #include "src/__support/FPUtil/Hypot.h"
 #include "src/__support/FPUtil/bfloat16.h"
 #include "src/__support/common.h"
 #include "src/__support/macros/config.h"
-#include "src/math/hypotbf16.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
@@ -18,5 +18,4 @@ LLVM_LIBC_FUNCTION(bfloat16, hypotbf16, (bfloat16 x, bfloat16 y)) {
   return fputil::hypot<bfloat16>(x, y);
 }
 
-
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/test/src/math/exhaustive/hypotbf16_test.cpp b/libc/test/src/math/exhaustive/hypotbf16_test.cpp
index 4001d20f5b843..15d50a485bd9f 100644
--- a/libc/test/src/math/exhaustive/hypotbf16_test.cpp
+++ b/libc/test/src/math/exhaustive/hypotbf16_test.cpp
@@ -32,16 +32,16 @@ static constexpr uint16_t SUBNORM_POS_STOP = 0x007FU;
 static constexpr uint16_t SUBNORM_NEG_START = 0x8001U;
 static constexpr uint16_t SUBNORM_NEG_STOP = 0x807FU;
 
-TEST_F(LlvmLibcHypotBf16Test,NormalPositiveRange){
-    for (uint16_t v1 = POS_START; v1 <= POS_STOP; v1++) {
+TEST_F(LlvmLibcHypotBf16Test, NormalPositiveRange) {
+  for (uint16_t v1 = POS_START; v1 <= POS_STOP; v1++) {
     for (uint16_t v2 = v1; v2 <= POS_STOP; v2++) {
 
       bfloat16 x = FPBits(v1).get_val();
       bfloat16 y = FPBits(v2).get_val();
-        mpfr::BinaryInput<bfloat16> input{x, y};
+      mpfr::BinaryInput<bfloat16> input{x, y};
 
-        EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Hypot, input,
-                                       LIBC_NAMESPACE::hypotbf16(x, y), 0.5);
+      EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Hypot, input,
+                                     LIBC_NAMESPACE::hypotbf16(x, y), 0.5);
     }
   }
 }
@@ -52,10 +52,10 @@ TEST_F(LlvmLibcHypotBf16Test,NormalNegativeRange){
 
       bfloat16 x = FPBits(v1).get_val();
       bfloat16 y = FPBits(v2).get_val();
-        mpfr::BinaryInput<bfloat16> input{x, y};
+      mpfr::BinaryInput<bfloat16> input{x, y};
 
-        EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Hypot, input,
-                                       LIBC_NAMESPACE::hypotbf16(x, y), 0.5);
+      EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Hypot, input,
+                                     LIBC_NAMESPACE::hypotbf16(x, y), 0.5);
     }
   }
 }
@@ -66,10 +66,10 @@ TEST_F(LlvmLibcHypotBf16Test, SubnormalNegativeRange) {
 
       bfloat16 x = FPBits(v1).get_val();
       bfloat16 y = FPBits(v2).get_val();
-        mpfr::BinaryInput<bfloat16> input{x, y};
+      mpfr::BinaryInput<bfloat16> input{x, y};
 
-        EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Hypot, input,
-                                       LIBC_NAMESPACE::hypotbf16(x, y), 0.5);
+      EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Hypot, input,
+                                     LIBC_NAMESPACE::hypotbf16(x, y), 0.5);
     }
   }
 }
@@ -80,10 +80,10 @@ TEST_F(LlvmLibcHypotBf16Test, SubnormalPositiveRange) {
 
       bfloat16 x = FPBits(v1).get_val();
       bfloat16 y = FPBits(v2).get_val();
-        mpfr::BinaryInput<bfloat16> input{x, y};
+      mpfr::BinaryInput<bfloat16> input{x, y};
 
-        EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Hypot, input,
-                                       LIBC_NAMESPACE::hypotbf16(x, y), 0.5);
+      EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Hypot, input,
+                                     LIBC_NAMESPACE::hypotbf16(x, y), 0.5);
     }
   }
 }
@@ -94,10 +94,10 @@ TEST_F(LlvmLibcHypotBf16Test, SpecialNumbers) {
     for (size_t j = i; j < 6; ++j) {
       bfloat16 x = VALUES[i];
       bfloat16 y = VALUES[j];
-        mpfr::BinaryInput<bfloat16> input{x, y};
+      mpfr::BinaryInput<bfloat16> input{x, y};
 
-        EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Hypot, input,
-                                       LIBC_NAMESPACE::hypotbf16(x, y), 0.5);
+      EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Hypot, input,
+                                     LIBC_NAMESPACE::hypotbf16(x, y), 0.5);
     }
   }
 }
diff --git a/libc/test/src/math/smoke/hypotbf16_test.cpp b/libc/test/src/math/smoke/hypotbf16_test.cpp
index a0935a58d1f38..679ad9bd462a6 100644
--- a/libc/test/src/math/smoke/hypotbf16_test.cpp
+++ b/libc/test/src/math/smoke/hypotbf16_test.cpp
@@ -30,4 +30,3 @@ TEST_F(LlvmLibcHypotBf16Test, SpecialNumbers) {
     }
   }
 }
-

>From 4385826739910cc959c838f90dd2b97d0eb1b573 Mon Sep 17 00:00:00 2001
From: Sukumarsawant <sawantsukumar at gmail.com>
Date: Thu, 26 Feb 2026 12:33:52 +0530
Subject: [PATCH 11/19] formatted

---
 libc/test/src/math/exhaustive/hypotbf16_test.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libc/test/src/math/exhaustive/hypotbf16_test.cpp b/libc/test/src/math/exhaustive/hypotbf16_test.cpp
index 15d50a485bd9f..4001c0a35c914 100644
--- a/libc/test/src/math/exhaustive/hypotbf16_test.cpp
+++ b/libc/test/src/math/exhaustive/hypotbf16_test.cpp
@@ -46,8 +46,8 @@ TEST_F(LlvmLibcHypotBf16Test, NormalPositiveRange) {
   }
 }
 
-TEST_F(LlvmLibcHypotBf16Test,NormalNegativeRange){
-    for (uint16_t v1 = NEG_START; v1 <= NEG_STOP; v1++) {
+TEST_F(LlvmLibcHypotBf16Test, NormalNegativeRange) {
+  for (uint16_t v1 = NEG_START; v1 <= NEG_STOP; v1++) {
     for (uint16_t v2 = v1; v2 <= NEG_STOP; v2++) {
 
       bfloat16 x = FPBits(v1).get_val();

>From 6e2d8809d876b8bce8bb1a0ebe271922af729b14 Mon Sep 17 00:00:00 2001
From: Sukumarsawant <sawantsukumar at gmail.com>
Date: Thu, 26 Feb 2026 13:43:38 +0530
Subject: [PATCH 12/19] added missed dependency for bfloat

---
 libc/test/src/math/exhaustive/CMakeLists.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libc/test/src/math/exhaustive/CMakeLists.txt b/libc/test/src/math/exhaustive/CMakeLists.txt
index 037a69de4948f..3766f81d907c6 100644
--- a/libc/test/src/math/exhaustive/CMakeLists.txt
+++ b/libc/test/src/math/exhaustive/CMakeLists.txt
@@ -372,6 +372,7 @@ add_fp_unittest(
     .exhaustive_test
     libc.src.math.hypotbf16
     libc.src.__support.FPUtil.fp_bits
+    libc.src.__support.FPUtil.bfloat16
   LINK_LIBRARIES
     -lpthread
 )

>From 4216cf8b0d2e9e6445ffd44094cc329f4c199b36 Mon Sep 17 00:00:00 2001
From: Sukumarsawant <sawantsukumar at gmail.com>
Date: Sat, 28 Feb 2026 00:58:00 +0530
Subject: [PATCH 13/19] CHANGE: repositions in  entrypoints.txt

---
 libc/config/baremetal/aarch64/entrypoints.txt | 2 +-
 libc/config/baremetal/arm/entrypoints.txt     | 2 +-
 libc/config/baremetal/riscv/entrypoints.txt   | 2 +-
 libc/config/darwin/aarch64/entrypoints.txt    | 2 +-
 libc/config/darwin/x86_64/entrypoints.txt     | 2 +-
 libc/config/gpu/amdgpu/entrypoints.txt        | 2 +-
 libc/config/gpu/nvptx/entrypoints.txt         | 2 +-
 libc/config/linux/aarch64/entrypoints.txt     | 2 +-
 libc/config/linux/arm/entrypoints.txt         | 2 +-
 libc/config/linux/riscv/entrypoints.txt       | 2 +-
 libc/config/linux/x86_64/entrypoints.txt      | 2 +-
 libc/config/windows/entrypoints.txt           | 1 +
 12 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/libc/config/baremetal/aarch64/entrypoints.txt b/libc/config/baremetal/aarch64/entrypoints.txt
index a89f9bd65a043..0b1c2c08a631e 100644
--- a/libc/config/baremetal/aarch64/entrypoints.txt
+++ b/libc/config/baremetal/aarch64/entrypoints.txt
@@ -447,7 +447,6 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.getpayloadf
     libc.src.math.getpayloadl
     libc.src.math.hypot
-    libc.src.math.hypotbf16
     libc.src.math.hypotf
     libc.src.math.ilogb
     libc.src.math.ilogbf
@@ -811,6 +810,7 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
   libc.src.math.fromfpbf16
   libc.src.math.fromfpxbf16
   libc.src.math.getpayloadbf16
+  libc.src.math.hypotbf16
   libc.src.math.ilogbbf16
   libc.src.math.iscanonicalbf16
   libc.src.math.issignalingbf16
diff --git a/libc/config/baremetal/arm/entrypoints.txt b/libc/config/baremetal/arm/entrypoints.txt
index 4470208c6f211..ac3851a41ebaf 100644
--- a/libc/config/baremetal/arm/entrypoints.txt
+++ b/libc/config/baremetal/arm/entrypoints.txt
@@ -450,7 +450,6 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.getpayloadf
     libc.src.math.getpayloadl
     libc.src.math.hypot
-    libc.src.math.hypotbf16
     libc.src.math.hypotf
     libc.src.math.ilogb
     libc.src.math.ilogbf
@@ -814,6 +813,7 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
   libc.src.math.fromfpbf16
   libc.src.math.fromfpxbf16
   libc.src.math.getpayloadbf16
+  libc.src.math.hypotbf16
   libc.src.math.ilogbbf16
   libc.src.math.iscanonicalbf16
   libc.src.math.issignalingbf16
diff --git a/libc/config/baremetal/riscv/entrypoints.txt b/libc/config/baremetal/riscv/entrypoints.txt
index b23e8d71bac81..210dfe03383ac 100644
--- a/libc/config/baremetal/riscv/entrypoints.txt
+++ b/libc/config/baremetal/riscv/entrypoints.txt
@@ -448,7 +448,6 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.getpayloadf
     libc.src.math.getpayloadl
     libc.src.math.hypot
-    libc.src.math.hypotbf16
     libc.src.math.hypotf
     libc.src.math.ilogb
     libc.src.math.ilogbf
@@ -812,6 +811,7 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
   libc.src.math.fromfpbf16
   libc.src.math.fromfpxbf16
   libc.src.math.getpayloadbf16
+  libc.src.math.hypotbf16
   libc.src.math.ilogbbf16
   libc.src.math.iscanonicalbf16
   libc.src.math.issignalingbf16
diff --git a/libc/config/darwin/aarch64/entrypoints.txt b/libc/config/darwin/aarch64/entrypoints.txt
index 7f7a22fded002..bd91796d66fa3 100644
--- a/libc/config/darwin/aarch64/entrypoints.txt
+++ b/libc/config/darwin/aarch64/entrypoints.txt
@@ -263,7 +263,6 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.getpayloadf
     libc.src.math.getpayloadl
     libc.src.math.hypot
-    libc.src.math.hypotbf16
     libc.src.math.hypotf
     libc.src.math.ilogb
     libc.src.math.ilogbf
@@ -628,6 +627,7 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
   libc.src.math.fromfpbf16
   libc.src.math.fromfpxbf16
   libc.src.math.getpayloadbf16
+  libc.src.math.hypotbf16
   libc.src.math.ilogbbf16
   libc.src.math.iscanonicalbf16
   libc.src.math.issignalingbf16
diff --git a/libc/config/darwin/x86_64/entrypoints.txt b/libc/config/darwin/x86_64/entrypoints.txt
index 3d205b5a10895..d97474f0d7021 100644
--- a/libc/config/darwin/x86_64/entrypoints.txt
+++ b/libc/config/darwin/x86_64/entrypoints.txt
@@ -162,7 +162,6 @@ set(TARGET_LIBM_ENTRYPOINTS
     #libc.src.math.fsub
     #libc.src.math.fsubl
     #libc.src.math.hypot
-    #libc.src.math.hypotbf16
     #libc.src.math.hypotf
     #libc.src.math.ilogb
     #libc.src.math.ilogbf
@@ -270,6 +269,7 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
   libc.src.math.fromfpbf16
   libc.src.math.fromfpxbf16
   libc.src.math.getpayloadbf16
+  libc.src.math.hypotbf16
   libc.src.math.ilogbbf16
   libc.src.math.iscanonicalbf16
   libc.src.math.issignalingbf16
diff --git a/libc/config/gpu/amdgpu/entrypoints.txt b/libc/config/gpu/amdgpu/entrypoints.txt
index 39da9588ea28e..e31c8da3b230d 100644
--- a/libc/config/gpu/amdgpu/entrypoints.txt
+++ b/libc/config/gpu/amdgpu/entrypoints.txt
@@ -390,7 +390,6 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.getpayloadf
     libc.src.math.getpayloadl
     libc.src.math.hypot
-    libc.src.math.hypotbf16
     libc.src.math.hypotf
     libc.src.math.ilogb
     libc.src.math.ilogbf
@@ -653,6 +652,7 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
   libc.src.math.fromfpbf16
   libc.src.math.fromfpxbf16
   libc.src.math.getpayloadbf16
+  libc.src.math.hypotbf16
   libc.src.math.ilogbbf16
   libc.src.math.iscanonicalbf16
   libc.src.math.issignalingbf16
diff --git a/libc/config/gpu/nvptx/entrypoints.txt b/libc/config/gpu/nvptx/entrypoints.txt
index bfc562ba01c36..80775dcb006d6 100644
--- a/libc/config/gpu/nvptx/entrypoints.txt
+++ b/libc/config/gpu/nvptx/entrypoints.txt
@@ -391,7 +391,6 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.getpayloadf
     libc.src.math.getpayloadl
     libc.src.math.hypot
-    libc.src.math.hypotbf16
     libc.src.math.hypotf
     libc.src.math.ilogb
     libc.src.math.ilogbf
@@ -655,6 +654,7 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
   libc.src.math.fromfpbf16
   libc.src.math.fromfpxbf16
   libc.src.math.getpayloadbf16
+  libc.src.math.hypotbf16
   libc.src.math.ilogbbf16
   libc.src.math.iscanonicalbf16
   libc.src.math.issignalingbf16
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index b4483c2e67516..88a02c4cfe223 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -528,7 +528,6 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.getpayloadf
     libc.src.math.getpayloadl
     libc.src.math.hypot
-    libc.src.math.hypotbf16
     libc.src.math.hypotf
     libc.src.math.ilogb
     libc.src.math.ilogbf
@@ -884,6 +883,7 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
   libc.src.math.fromfpbf16
   libc.src.math.fromfpxbf16
   libc.src.math.getpayloadbf16
+  libc.src.math.hypotbf16
   libc.src.math.ilogbbf16
   libc.src.math.iscanonicalbf16
   libc.src.math.issignalingbf16
diff --git a/libc/config/linux/arm/entrypoints.txt b/libc/config/linux/arm/entrypoints.txt
index 7c3c932663de9..fbdfdceb6b49d 100644
--- a/libc/config/linux/arm/entrypoints.txt
+++ b/libc/config/linux/arm/entrypoints.txt
@@ -349,7 +349,6 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.getpayloadf
     libc.src.math.getpayloadl
     libc.src.math.hypot
-    libc.src.math.hypotbf16
     libc.src.math.hypotf
     libc.src.math.ilogb
     libc.src.math.ilogbf
@@ -497,6 +496,7 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
   libc.src.math.fromfpbf16
   libc.src.math.fromfpxbf16
   libc.src.math.getpayloadbf16
+  libc.src.math.hypotbf16
   libc.src.math.ilogbbf16
   libc.src.math.iscanonicalbf16
   libc.src.math.issignalingbf16
diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt
index edede92ed9565..e2113f288d0ed 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -537,7 +537,6 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.getpayloadf
     libc.src.math.getpayloadl
     libc.src.math.hypot
-    libc.src.math.hypotbf16
     libc.src.math.hypotf
     libc.src.math.ilogb
     libc.src.math.ilogbf
@@ -905,6 +904,7 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
   libc.src.math.fromfpbf16
   libc.src.math.fromfpxbf16
   libc.src.math.getpayloadbf16
+  libc.src.math.hypotbf16
   libc.src.math.ilogbbf16
   libc.src.math.iscanonicalbf16
   libc.src.math.issignalingbf16
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index 04ad792d30512..2b9a0fe0a8c0e 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -579,7 +579,6 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.getpayloadf
     libc.src.math.getpayloadl
     libc.src.math.hypot
-    libc.src.math.hypotbf16
     libc.src.math.hypotf
     libc.src.math.ilogb
     libc.src.math.ilogbf
@@ -952,6 +951,7 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
   libc.src.math.fromfpbf16
   libc.src.math.fromfpxbf16
   libc.src.math.getpayloadbf16
+  libc.src.math.hypotbf16
   libc.src.math.ilogbbf16
   libc.src.math.iscanonicalbf16
   libc.src.math.issignalingbf16
diff --git a/libc/config/windows/entrypoints.txt b/libc/config/windows/entrypoints.txt
index 474e970e4678d..ca8a18c292d68 100644
--- a/libc/config/windows/entrypoints.txt
+++ b/libc/config/windows/entrypoints.txt
@@ -343,6 +343,7 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
   libc.src.math.fromfpbf16
   libc.src.math.fromfpxbf16
   libc.src.math.getpayloadbf16
+  libc.src.math.hypotbf16
   libc.src.math.ilogbbf16
   libc.src.math.iscanonicalbf16
   libc.src.math.issignalingbf16

>From d8d16ee0368561ebaf29672d9f285b572dce6d95 Mon Sep 17 00:00:00 2001
From: Sukumarsawant <sawantsukumar at gmail.com>
Date: Sat, 28 Feb 2026 01:36:26 +0530
Subject: [PATCH 14/19] REFACTOR: refactored hypotbf16 to header

---
 libc/config/windows/entrypoints.txt           |  1 -
 libc/shared/math.h                            |  1 +
 libc/shared/math/hypotbf16.h                  | 26 +++++++++++++++++
 libc/src/__support/math/CMakeLists.txt        | 11 +++++++
 libc/src/__support/math/hypotbf16.h           | 29 +++++++++++++++++++
 libc/src/math/generic/CMakeLists.txt          |  5 +---
 libc/src/math/generic/hypotbf16.cpp           |  7 ++---
 libc/test/shared/CMakeLists.txt               |  1 +
 libc/test/shared/shared_math_test.cpp         |  3 ++
 .../llvm-project-overlay/libc/BUILD.bazel     | 18 ++++++++++++
 10 files changed, 92 insertions(+), 10 deletions(-)
 create mode 100644 libc/shared/math/hypotbf16.h
 create mode 100644 libc/src/__support/math/hypotbf16.h

diff --git a/libc/config/windows/entrypoints.txt b/libc/config/windows/entrypoints.txt
index ca8a18c292d68..5bd4a698129d8 100644
--- a/libc/config/windows/entrypoints.txt
+++ b/libc/config/windows/entrypoints.txt
@@ -222,7 +222,6 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.fsub
     libc.src.math.fsubl
     libc.src.math.hypot
-    libc.src.math.hypotbf16
     libc.src.math.hypotf
     libc.src.math.ilogb
     libc.src.math.ilogbf
diff --git a/libc/shared/math.h b/libc/shared/math.h
index 9f152a281cc72..553eb5ad1fb19 100644
--- a/libc/shared/math.h
+++ b/libc/shared/math.h
@@ -119,6 +119,7 @@
 #include "math/getpayloadf128.h"
 #include "math/getpayloadf16.h"
 #include "math/getpayloadl.h"
+#include "math/hypotbf16.h"
 #include "math/hypotf.h"
 #include "math/hypotf16.h"
 #include "math/ilogb.h"
diff --git a/libc/shared/math/hypotbf16.h b/libc/shared/math/hypotbf16.h
new file mode 100644
index 0000000000000..d134d84a304aa
--- /dev/null
+++ b/libc/shared/math/hypotbf16.h
@@ -0,0 +1,26 @@
+//===-- Shared hypotbf16 function -------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_HYPOTBF16_H
+#define LLVM_LIBC_SHARED_MATH_HYPOTBF16_H
+
+#include "shared/libc_common.h"
+
+#include "src/__support/math/hypotbf16.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace shared {
+
+using math::hypotbf16;
+
+} // namespace shared
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_HYPOTBF16_H
diff --git a/libc/src/__support/math/CMakeLists.txt b/libc/src/__support/math/CMakeLists.txt
index 99bf456ff0bca..f5ba6bbab4865 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -1616,6 +1616,17 @@ add_header_library(
     libc.src.__support.macros.optimization
 )
 
+add_header_library(
+  hypotbf16
+  HDRS
+    hypotbf16.h
+  DEPENDS
+    libc.src.__support.FPUtil.Hypot
+    libc.src.__support.FPUtil.bfloat16
+    libc.src.__support.common
+    libc.src.__support.macros.config
+)
+
 add_header_library(
   hypotf16
   HDRS
diff --git a/libc/src/__support/math/hypotbf16.h b/libc/src/__support/math/hypotbf16.h
new file mode 100644
index 0000000000000..ef57ce6bebcfa
--- /dev/null
+++ b/libc/src/__support/math/hypotbf16.h
@@ -0,0 +1,29 @@
+//===-- Implementation header for fmabf16 -----------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_FMABF16_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_FMABF16_H
+
+#include "src/__support/FPUtil/Hypot.h"
+#include "src/__support/FPUtil/bfloat16.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+LIBC_INLINE bfloat16 hypotbf16(bfloat16 x, bfloat16 y) {
+  return fputil::hypot<bfloat16>(x, y);
+}
+
+} // namespace math
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_HYPOTBF16_H
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index e8ab0ccf3efc8..c97b4df0b3fbf 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -3047,10 +3047,7 @@ add_entrypoint_object(
   HDRS
     ../hypotbf16.h
   DEPENDS
-    libc.src.__support.FPUtil.hypot
-    libc.src.__support.FPUtil.bfloat16
-    libc.src.__support.common
-    libc.src.__support.macros.config
+    libc.src.__support.math.hypotbf16
 )
 
 add_entrypoint_object(
diff --git a/libc/src/math/generic/hypotbf16.cpp b/libc/src/math/generic/hypotbf16.cpp
index 6852d6fa77035..0c1a3ed84021b 100644
--- a/libc/src/math/generic/hypotbf16.cpp
+++ b/libc/src/math/generic/hypotbf16.cpp
@@ -7,15 +7,12 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/math/hypotbf16.h"
-#include "src/__support/FPUtil/Hypot.h"
-#include "src/__support/FPUtil/bfloat16.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/hypotbf16.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
 LLVM_LIBC_FUNCTION(bfloat16, hypotbf16, (bfloat16 x, bfloat16 y)) {
-  return fputil::hypot<bfloat16>(x, y);
+  return math::hypotbf16(x, y);
 }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/test/shared/CMakeLists.txt b/libc/test/shared/CMakeLists.txt
index 4048015fbdb26..64739b9eaf572 100644
--- a/libc/test/shared/CMakeLists.txt
+++ b/libc/test/shared/CMakeLists.txt
@@ -117,6 +117,7 @@ add_fp_unittest(
     libc.src.__support.math.getpayloadf16
     libc.src.__support.math.getpayloadl
     libc.src.__support.math.hypotf
+    libc.src.__support.math.hypotbf16
     libc.src.__support.math.hypotf16
     libc.src.__support.math.ilogb
     libc.src.__support.math.ilogbf
diff --git a/libc/test/shared/shared_math_test.cpp b/libc/test/shared/shared_math_test.cpp
index 1d17cf841deee..882a830498bdb 100644
--- a/libc/test/shared/shared_math_test.cpp
+++ b/libc/test/shared/shared_math_test.cpp
@@ -385,6 +385,9 @@ TEST(LlvmLibcSharedMathTest, AllBFloat16) {
   EXPECT_FP_EQ(bfloat16(-1.0),
                LIBC_NAMESPACE::shared::getpayloadbf16(&getpayloadbf16_x));
 
+  EXPECT_FP_EQ(bfloat16(5.0),
+               LIBC_NAMESPACE::shared::hypotbf16(bfloat16(4.0), bfloat16(3.0)));
+
   bfloat16 setpayloadbf16_res = bfloat16(0.0);
   EXPECT_EQ(0, LIBC_NAMESPACE::shared::setpayloadbf16(&setpayloadbf16_res,
                                                       bfloat16(0.0)));
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index e142bd25d69f9..0ebbf9aa3f91a 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -5040,6 +5040,17 @@ libc_support_library(
     ],
 )
 
+libc_support_library(
+    name = "__support_math_hypotbf16",
+    hdrs = ["src/__support/math/hypotbf16.h"],
+    deps = [
+        ":__support_fputil_hypot",
+        ":__support_fputil_bfloat16",
+        ":__support_common",
+        ":__support_macros_config",
+    ],
+)
+
 libc_support_library(
     name = "__support_math_hypotf16",
     hdrs = ["src/__support/math/hypotf16.h"],
@@ -6576,6 +6587,13 @@ libc_math_function(
     ],
 )
 
+libc_math_function(
+    name = "hypotbf16",
+    additional_deps = [
+        ":__support_math_hypotbf16",
+    ],
+)
+
 libc_math_function(
     name = "hypotf16",
     additional_deps = [

>From be062a68ba4cc2dca57b1e3306856d895c183628 Mon Sep 17 00:00:00 2001
From: Sukumarsawant <sawantsukumar at gmail.com>
Date: Sat, 28 Feb 2026 01:47:26 +0530
Subject: [PATCH 15/19] FIX: Typo

---
 libc/src/__support/math/hypotbf16.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libc/src/__support/math/hypotbf16.h b/libc/src/__support/math/hypotbf16.h
index ef57ce6bebcfa..e04013e4e3d68 100644
--- a/libc/src/__support/math/hypotbf16.h
+++ b/libc/src/__support/math/hypotbf16.h
@@ -1,4 +1,4 @@
-//===-- Implementation header for fmabf16 -----------------------*- C++ -*-===//
+//===-- Implementation header for hypotbf16 ---------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,8 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_FMABF16_H
-#define LLVM_LIBC_SRC___SUPPORT_MATH_FMABF16_H
+#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_HYPOTBF16_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_HYPOTBF16_H
 
 #include "src/__support/FPUtil/Hypot.h"
 #include "src/__support/FPUtil/bfloat16.h"

>From 6def72a6305833a40b552e52a3158bdc40cbdfef Mon Sep 17 00:00:00 2001
From: Sukumarsawant <sawantsukumar at gmail.com>
Date: Sat, 28 Feb 2026 16:55:16 +0530
Subject: [PATCH 16/19] FORMAT: Bazel

---
 utils/bazel/llvm-project-overlay/libc/BUILD.bazel | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index 0ebbf9aa3f91a..babcd7e772967 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -5044,9 +5044,9 @@ libc_support_library(
     name = "__support_math_hypotbf16",
     hdrs = ["src/__support/math/hypotbf16.h"],
     deps = [
-        ":__support_fputil_hypot",
-        ":__support_fputil_bfloat16",
         ":__support_common",
+        ":__support_fputil_bfloat16",
+        ":__support_fputil_hypot",
         ":__support_macros_config",
     ],
 )

>From addab4be4662b5096f96f4ffcce24f462ebd8283 Mon Sep 17 00:00:00 2001
From: Sukumarsawant <sawantsukumar at gmail.com>
Date: Sun, 1 Mar 2026 23:57:50 +0530
Subject: [PATCH 17/19] remove: removed redundancy

---
 .../src/math/exhaustive/hypotbf16_test.cpp    | 39 +------------------
 1 file changed, 2 insertions(+), 37 deletions(-)

diff --git a/libc/test/src/math/exhaustive/hypotbf16_test.cpp b/libc/test/src/math/exhaustive/hypotbf16_test.cpp
index 4001c0a35c914..41e64b56caa3c 100644
--- a/libc/test/src/math/exhaustive/hypotbf16_test.cpp
+++ b/libc/test/src/math/exhaustive/hypotbf16_test.cpp
@@ -24,15 +24,7 @@ static constexpr uint16_t POS_STOP = 0x7f80U;
 static constexpr uint16_t NEG_START = 0x8000U;
 static constexpr uint16_t NEG_STOP = 0xff80U;
 
-// Subnormal range (positive)
-static constexpr uint16_t SUBNORM_POS_START = 0x0001U;
-static constexpr uint16_t SUBNORM_POS_STOP = 0x007FU;
-
-// Subnormal range (negative)
-static constexpr uint16_t SUBNORM_NEG_START = 0x8001U;
-static constexpr uint16_t SUBNORM_NEG_STOP = 0x807FU;
-
-TEST_F(LlvmLibcHypotBf16Test, NormalPositiveRange) {
+TEST_F(LlvmLibcHypotBf16Test, PositiveRange) {
   for (uint16_t v1 = POS_START; v1 <= POS_STOP; v1++) {
     for (uint16_t v2 = v1; v2 <= POS_STOP; v2++) {
 
@@ -46,7 +38,7 @@ TEST_F(LlvmLibcHypotBf16Test, NormalPositiveRange) {
   }
 }
 
-TEST_F(LlvmLibcHypotBf16Test, NormalNegativeRange) {
+TEST_F(LlvmLibcHypotBf16Test, NegativeRange) {
   for (uint16_t v1 = NEG_START; v1 <= NEG_STOP; v1++) {
     for (uint16_t v2 = v1; v2 <= NEG_STOP; v2++) {
 
@@ -60,33 +52,6 @@ TEST_F(LlvmLibcHypotBf16Test, NormalNegativeRange) {
   }
 }
 
-TEST_F(LlvmLibcHypotBf16Test, SubnormalNegativeRange) {
-  for (uint16_t v1 = SUBNORM_NEG_START; v1 <= SUBNORM_NEG_STOP; v1++) {
-    for (uint16_t v2 = v1; v2 <= SUBNORM_NEG_STOP; v2++) {
-
-      bfloat16 x = FPBits(v1).get_val();
-      bfloat16 y = FPBits(v2).get_val();
-      mpfr::BinaryInput<bfloat16> input{x, y};
-
-      EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Hypot, input,
-                                     LIBC_NAMESPACE::hypotbf16(x, y), 0.5);
-    }
-  }
-}
-
-TEST_F(LlvmLibcHypotBf16Test, SubnormalPositiveRange) {
-  for (uint16_t v1 = SUBNORM_POS_START; v1 <= SUBNORM_POS_STOP; v1++) {
-    for (uint16_t v2 = v1; v2 <= SUBNORM_POS_STOP; v2++) {
-
-      bfloat16 x = FPBits(v1).get_val();
-      bfloat16 y = FPBits(v2).get_val();
-      mpfr::BinaryInput<bfloat16> input{x, y};
-
-      EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Hypot, input,
-                                     LIBC_NAMESPACE::hypotbf16(x, y), 0.5);
-    }
-  }
-}
 TEST_F(LlvmLibcHypotBf16Test, SpecialNumbers) {
   constexpr bfloat16 VALUES[] = {zero,    neg_zero,   inf,
                                  neg_inf, min_normal, max_normal};

>From 709b7f4f8719d3ddd30e6f6b175a3c3c5f8f947b Mon Sep 17 00:00:00 2001
From: Sukumarsawant <sawantsukumar at gmail.com>
Date: Mon, 2 Mar 2026 10:59:51 +0530
Subject: [PATCH 18/19] chore: smoke uses HypotTest.h now

---
 libc/test/src/math/smoke/hypotbf16_test.cpp | 25 +++++----------------
 1 file changed, 5 insertions(+), 20 deletions(-)

diff --git a/libc/test/src/math/smoke/hypotbf16_test.cpp b/libc/test/src/math/smoke/hypotbf16_test.cpp
index 679ad9bd462a6..f406dd71c659e 100644
--- a/libc/test/src/math/smoke/hypotbf16_test.cpp
+++ b/libc/test/src/math/smoke/hypotbf16_test.cpp
@@ -6,27 +6,12 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "src/__support/FPUtil/bfloat16.h"
-#include "src/math/hypotbf16.h"
-#include "test/UnitTest/FPMatcher.h"
-#include "test/UnitTest/Test.h"
-#include "utils/MPFRWrapper/MPFRUtils.h"
+#include "HypotTest.h"
 
-using LlvmLibcHypotBf16Test = LIBC_NAMESPACE::testing::FPTest<bfloat16>;
+#include "src/math/hypotbf16.h"
 
-namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
+using LlvmLibcHypotBf16Test = HypotTestTemplate<bfloat16>;
 
 TEST_F(LlvmLibcHypotBf16Test, SpecialNumbers) {
-  constexpr bfloat16 VAL[] = {zero,    neg_zero,   inf,
-                              neg_inf, min_normal, max_normal};
-  for (size_t v1 = 0; v1 < 6; ++v1) {
-    for (size_t v2 = v1; v2 < 6; ++v2) {
-
-      bfloat16 x = VAL[v1];
-      bfloat16 y = VAL[v2];
-      mpfr::BinaryInput<bfloat16> input{x, y};
-      EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Hypot, input,
-                                     LIBC_NAMESPACE::hypotbf16(x, y), 0.5);
-    }
-  }
-}
+  test_special_numbers(&LIBC_NAMESPACE::hypotbf16);
+}
\ No newline at end of file

>From e90c0f6fb196733308d6440831cc818de97f3889 Mon Sep 17 00:00:00 2001
From: Sukumarsawant <sawantsukumar at gmail.com>
Date: Mon, 2 Mar 2026 11:05:28 +0530
Subject: [PATCH 19/19] chore: cmake updated

---
 libc/test/src/math/smoke/CMakeLists.txt     | 4 +---
 libc/test/src/math/smoke/hypotbf16_test.cpp | 1 +
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index 83a4e337c514b..5b9de4fe04f9e 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -3754,9 +3754,7 @@ add_fp_unittest(
   DEPENDS
     libc.src.math.hypotbf16
     libc.src.__support.FPUtil.bfloat16
-    libc.test.UnitTest.FPMatcher
-    libc.test.UnitTest.Test
-    libc.utils.MPFRWrapper.MPFRUtils
+    libc.src.__support.FPUtil.fp_bits
 )
 
 add_fp_unittest(
diff --git a/libc/test/src/math/smoke/hypotbf16_test.cpp b/libc/test/src/math/smoke/hypotbf16_test.cpp
index f406dd71c659e..892017c309a72 100644
--- a/libc/test/src/math/smoke/hypotbf16_test.cpp
+++ b/libc/test/src/math/smoke/hypotbf16_test.cpp
@@ -8,6 +8,7 @@
 
 #include "HypotTest.h"
 
+#include "src/__support/FPUtil/bfloat16.h"
 #include "src/math/hypotbf16.h"
 
 using LlvmLibcHypotBf16Test = HypotTestTemplate<bfloat16>;



More information about the libc-commits mailing list