[libc-commits] [libc] [llvm] [libc][math] Refactor nextdown family to header-only (PR #181679)
via libc-commits
libc-commits at lists.llvm.org
Tue Feb 17 21:16:11 PST 2026
https://github.com/AnonMiraj updated https://github.com/llvm/llvm-project/pull/181679
>From 1048492630b59293a509c45896d687c1531bb657 Mon Sep 17 00:00:00 2001
From: Ezzeldin Ibrahim <ezzibrahimx at gmail.com>
Date: Mon, 16 Feb 2026 16:44:09 +0200
Subject: [PATCH 1/4] [libc][math] Refactor nextdown family to header-only
---
libc/shared/math.h | 6 ++
libc/shared/math/nextdown.h | 23 +++++
libc/shared/math/nextdownbf16.h | 23 +++++
libc/shared/math/nextdownf.h | 23 +++++
libc/shared/math/nextdownf128.h | 29 ++++++
libc/shared/math/nextdownf16.h | 29 ++++++
libc/shared/math/nextdownl.h | 23 +++++
libc/src/__support/math/CMakeLists.txt | 57 ++++++++++++
libc/src/__support/math/nextdown.h | 26 ++++++
libc/src/__support/math/nextdownbf16.h | 27 ++++++
libc/src/__support/math/nextdownf.h | 26 ++++++
libc/src/__support/math/nextdownf128.h | 32 +++++++
libc/src/__support/math/nextdownf16.h | 32 +++++++
libc/src/__support/math/nextdownl.h | 26 ++++++
libc/src/math/generic/CMakeLists.txt | 18 ++--
libc/src/math/generic/nextdown.cpp | 8 +-
libc/src/math/generic/nextdownbf16.cpp | 7 +-
libc/src/math/generic/nextdownf.cpp | 8 +-
libc/src/math/generic/nextdownf128.cpp | 6 +-
libc/src/math/generic/nextdownf16.cpp | 6 +-
libc/src/math/generic/nextdownl.cpp | 6 +-
libc/test/shared/CMakeLists.txt | 6 ++
libc/test/shared/shared_math_test.cpp | 14 +++
.../llvm-project-overlay/libc/BUILD.bazel | 92 ++++++++++++++++++-
24 files changed, 507 insertions(+), 46 deletions(-)
create mode 100644 libc/shared/math/nextdown.h
create mode 100644 libc/shared/math/nextdownbf16.h
create mode 100644 libc/shared/math/nextdownf.h
create mode 100644 libc/shared/math/nextdownf128.h
create mode 100644 libc/shared/math/nextdownf16.h
create mode 100644 libc/shared/math/nextdownl.h
create mode 100644 libc/src/__support/math/nextdown.h
create mode 100644 libc/src/__support/math/nextdownbf16.h
create mode 100644 libc/src/__support/math/nextdownf.h
create mode 100644 libc/src/__support/math/nextdownf128.h
create mode 100644 libc/src/__support/math/nextdownf16.h
create mode 100644 libc/src/__support/math/nextdownl.h
diff --git a/libc/shared/math.h b/libc/shared/math.h
index 828980a3500df..c3e49b2cce577 100644
--- a/libc/shared/math.h
+++ b/libc/shared/math.h
@@ -115,6 +115,12 @@
#include "math/logbf16.h"
#include "math/logf.h"
#include "math/logf16.h"
+#include "math/nextdown.h"
+#include "math/nextdownbf16.h"
+#include "math/nextdownf.h"
+#include "math/nextdownf128.h"
+#include "math/nextdownf16.h"
+#include "math/nextdownl.h"
#include "math/pow.h"
#include "math/powf.h"
#include "math/rsqrtf.h"
diff --git a/libc/shared/math/nextdown.h b/libc/shared/math/nextdown.h
new file mode 100644
index 0000000000000..5ea6c0ee5b364
--- /dev/null
+++ b/libc/shared/math/nextdown.h
@@ -0,0 +1,23 @@
+//===-- Shared nextdown 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_NEXTDOWN_H
+#define LLVM_LIBC_SHARED_MATH_NEXTDOWN_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/nextdown.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::nextdown;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_NEXTDOWN_H
diff --git a/libc/shared/math/nextdownbf16.h b/libc/shared/math/nextdownbf16.h
new file mode 100644
index 0000000000000..859e8b2ee9a30
--- /dev/null
+++ b/libc/shared/math/nextdownbf16.h
@@ -0,0 +1,23 @@
+//===-- Shared nextdownbf16 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_NEXTDOWNBF16_H
+#define LLVM_LIBC_SHARED_MATH_NEXTDOWNBF16_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/nextdownbf16.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::nextdownbf16;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_NEXTDOWNBF16_H
diff --git a/libc/shared/math/nextdownf.h b/libc/shared/math/nextdownf.h
new file mode 100644
index 0000000000000..1b5a118a7af4b
--- /dev/null
+++ b/libc/shared/math/nextdownf.h
@@ -0,0 +1,23 @@
+//===-- Shared nextdownf 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_NEXTDOWNF_H
+#define LLVM_LIBC_SHARED_MATH_NEXTDOWNF_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/nextdownf.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::nextdownf;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_NEXTDOWNF_H
diff --git a/libc/shared/math/nextdownf128.h b/libc/shared/math/nextdownf128.h
new file mode 100644
index 0000000000000..1632717defc1a
--- /dev/null
+++ b/libc/shared/math/nextdownf128.h
@@ -0,0 +1,29 @@
+//===-- Shared nextdownf128 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_NEXTDOWNF128_H
+#define LLVM_LIBC_SHARED_MATH_NEXTDOWNF128_H
+
+#include "include/llvm-libc-types/float128.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT128
+
+#include "shared/libc_common.h"
+#include "src/__support/math/nextdownf128.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::nextdownf128;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT128
+
+#endif // LLVM_LIBC_SHARED_MATH_NEXTDOWNF128_H
diff --git a/libc/shared/math/nextdownf16.h b/libc/shared/math/nextdownf16.h
new file mode 100644
index 0000000000000..f472ec8bd091f
--- /dev/null
+++ b/libc/shared/math/nextdownf16.h
@@ -0,0 +1,29 @@
+//===-- Shared nextdownf16 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_NEXTDOWNF16_H
+#define LLVM_LIBC_SHARED_MATH_NEXTDOWNF16_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "shared/libc_common.h"
+#include "src/__support/math/nextdownf16.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::nextdownf16;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT16
+
+#endif // LLVM_LIBC_SHARED_MATH_NEXTDOWNF16_H
diff --git a/libc/shared/math/nextdownl.h b/libc/shared/math/nextdownl.h
new file mode 100644
index 0000000000000..f8d0a98e8e944
--- /dev/null
+++ b/libc/shared/math/nextdownl.h
@@ -0,0 +1,23 @@
+//===-- Shared nextdownl 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_NEXTDOWNL_H
+#define LLVM_LIBC_SHARED_MATH_NEXTDOWNL_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/nextdownl.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::nextdownl;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_NEXTDOWNL_H
diff --git a/libc/src/__support/math/CMakeLists.txt b/libc/src/__support/math/CMakeLists.txt
index af2c66597b75a..ad82c2f3dfd3c 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -1287,6 +1287,63 @@ add_header_library(
libc.src.__support.macros.config
)
+add_header_library(
+ nextdown
+ HDRS
+ nextdown.h
+ DEPENDS
+ libc.src.__support.FPUtil.manipulation_functions
+ libc.src.__support.macros.config
+)
+
+add_header_library(
+ nextdownbf16
+ HDRS
+ nextdownbf16.h
+ DEPENDS
+ libc.src.__support.FPUtil.bfloat16
+ libc.src.__support.FPUtil.manipulation_functions
+ libc.src.__support.macros.config
+)
+
+add_header_library(
+ nextdownf
+ HDRS
+ nextdownf.h
+ DEPENDS
+ libc.src.__support.FPUtil.manipulation_functions
+ libc.src.__support.macros.config
+)
+
+add_header_library(
+ nextdownf128
+ HDRS
+ nextdownf128.h
+ DEPENDS
+ libc.include.llvm-libc-types.float128
+ libc.src.__support.FPUtil.manipulation_functions
+ libc.src.__support.macros.config
+)
+
+add_header_library(
+ nextdownf16
+ HDRS
+ nextdownf16.h
+ DEPENDS
+ libc.include.llvm-libc-macros.float16_macros
+ libc.src.__support.FPUtil.manipulation_functions
+ libc.src.__support.macros.config
+)
+
+add_header_library(
+ nextdownl
+ HDRS
+ nextdownl.h
+ DEPENDS
+ libc.src.__support.FPUtil.manipulation_functions
+ libc.src.__support.macros.config
+)
+
add_header_library(
range_reduction_double
HDRS
diff --git a/libc/src/__support/math/nextdown.h b/libc/src/__support/math/nextdown.h
new file mode 100644
index 0000000000000..67deeb715536f
--- /dev/null
+++ b/libc/src/__support/math/nextdown.h
@@ -0,0 +1,26 @@
+//===-- Implementation header for nextdown ----------------------*- 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_NEXTDOWN_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_NEXTDOWN_H
+
+#include "src/__support/FPUtil/ManipulationFunctions.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+LIBC_INLINE constexpr double nextdown(double x) {
+ return fputil::nextupdown</*IsDown=*/true>(x);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_NEXTDOWN_H
diff --git a/libc/src/__support/math/nextdownbf16.h b/libc/src/__support/math/nextdownbf16.h
new file mode 100644
index 0000000000000..e09dce316adbf
--- /dev/null
+++ b/libc/src/__support/math/nextdownbf16.h
@@ -0,0 +1,27 @@
+//===-- Implementation header for nextdownbf16 ------------------*- 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_NEXTDOWNBF16_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_NEXTDOWNBF16_H
+
+#include "src/__support/FPUtil/ManipulationFunctions.h"
+#include "src/__support/FPUtil/bfloat16.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+LIBC_INLINE constexpr bfloat16 nextdownbf16(bfloat16 x) {
+ return fputil::nextupdown</*IsDown=*/true>(x);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_NEXTDOWNBF16_H
diff --git a/libc/src/__support/math/nextdownf.h b/libc/src/__support/math/nextdownf.h
new file mode 100644
index 0000000000000..580eca4e05881
--- /dev/null
+++ b/libc/src/__support/math/nextdownf.h
@@ -0,0 +1,26 @@
+//===-- Implementation header for nextdownf ---------------------*- 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_NEXTDOWNF_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_NEXTDOWNF_H
+
+#include "src/__support/FPUtil/ManipulationFunctions.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+LIBC_INLINE constexpr float nextdownf(float x) {
+ return fputil::nextupdown</*IsDown=*/true>(x);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_NEXTDOWNF_H
diff --git a/libc/src/__support/math/nextdownf128.h b/libc/src/__support/math/nextdownf128.h
new file mode 100644
index 0000000000000..8f5e5c015efe4
--- /dev/null
+++ b/libc/src/__support/math/nextdownf128.h
@@ -0,0 +1,32 @@
+//===-- Implementation header for nextdownf128 ------------------*- 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_NEXTDOWNF128_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_NEXTDOWNF128_H
+
+#include "include/llvm-libc-types/float128.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT128
+
+#include "src/__support/FPUtil/ManipulationFunctions.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+LIBC_INLINE constexpr float128 nextdownf128(float128 x) {
+ return fputil::nextupdown</*IsDown=*/true>(x);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT128
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_NEXTDOWNF128_H
diff --git a/libc/src/__support/math/nextdownf16.h b/libc/src/__support/math/nextdownf16.h
new file mode 100644
index 0000000000000..6ce4b77947ac0
--- /dev/null
+++ b/libc/src/__support/math/nextdownf16.h
@@ -0,0 +1,32 @@
+//===-- Implementation header for nextdownf16 -------------------*- 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_NEXTDOWNF16_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_NEXTDOWNF16_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "src/__support/FPUtil/ManipulationFunctions.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+LIBC_INLINE constexpr float16 nextdownf16(float16 x) {
+ return fputil::nextupdown</*IsDown=*/true>(x);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT16
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_NEXTDOWNF16_H
diff --git a/libc/src/__support/math/nextdownl.h b/libc/src/__support/math/nextdownl.h
new file mode 100644
index 0000000000000..235186d0b2d43
--- /dev/null
+++ b/libc/src/__support/math/nextdownl.h
@@ -0,0 +1,26 @@
+//===-- Implementation header for nextdownl ---------------------*- 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_NEXTDOWNL_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_NEXTDOWNL_H
+
+#include "src/__support/FPUtil/ManipulationFunctions.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+LIBC_INLINE constexpr long double nextdownl(long double x) {
+ return fputil::nextupdown</*IsDown=*/true>(x);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_NEXTDOWNL_H
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index 47101706ce4c8..40142279d48af 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -3525,7 +3525,7 @@ add_entrypoint_object(
HDRS
../nextdown.h
DEPENDS
- libc.src.__support.FPUtil.manipulation_functions
+ libc.src.__support.math.nextdown
)
add_entrypoint_object(
@@ -3535,7 +3535,7 @@ add_entrypoint_object(
HDRS
../nextdownl.h
DEPENDS
- libc.src.__support.FPUtil.manipulation_functions
+ libc.src.__support.math.nextdownl
)
add_entrypoint_object(
@@ -3545,7 +3545,7 @@ add_entrypoint_object(
HDRS
../nextdownf.h
DEPENDS
- libc.src.__support.FPUtil.manipulation_functions
+ libc.src.__support.math.nextdownf
)
add_entrypoint_object(
@@ -3555,8 +3555,7 @@ add_entrypoint_object(
HDRS
../nextdownf16.h
DEPENDS
- libc.src.__support.macros.properties.types
- libc.src.__support.FPUtil.manipulation_functions
+ libc.src.__support.math.nextdownf16
)
add_entrypoint_object(
@@ -3566,8 +3565,7 @@ add_entrypoint_object(
HDRS
../nextdownf128.h
DEPENDS
- libc.src.__support.macros.properties.types
- libc.src.__support.FPUtil.manipulation_functions
+ libc.src.__support.math.nextdownf128
)
add_entrypoint_object(
@@ -3577,11 +3575,7 @@ add_entrypoint_object(
HDRS
../nextdownbf16.h
DEPENDS
- libc.src.__support.common
- libc.src.__support.FPUtil.bfloat16
- libc.src.__support.FPUtil.manipulation_functions
- libc.src.__support.macros.config
- libc.src.__support.macros.properties.types
+ libc.src.__support.math.nextdownbf16
)
add_entrypoint_object(
diff --git a/libc/src/math/generic/nextdown.cpp b/libc/src/math/generic/nextdown.cpp
index 90a91435f6129..5c328dae0b2e4 100644
--- a/libc/src/math/generic/nextdown.cpp
+++ b/libc/src/math/generic/nextdown.cpp
@@ -7,14 +7,10 @@
//===----------------------------------------------------------------------===//
#include "src/math/nextdown.h"
-#include "src/__support/FPUtil/ManipulationFunctions.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/nextdown.h"
namespace LIBC_NAMESPACE_DECL {
-LLVM_LIBC_FUNCTION(double, nextdown, (double x)) {
- return fputil::nextupdown</*IsDown=*/true>(x);
-}
+LLVM_LIBC_FUNCTION(double, nextdown, (double x)) { return math::nextdown(x); }
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/nextdownbf16.cpp b/libc/src/math/generic/nextdownbf16.cpp
index 2115df95ff072..e2e11005c1cf1 100644
--- a/libc/src/math/generic/nextdownbf16.cpp
+++ b/libc/src/math/generic/nextdownbf16.cpp
@@ -7,15 +7,12 @@
//===----------------------------------------------------------------------===//
#include "src/math/nextdownbf16.h"
-#include "src/__support/FPUtil/ManipulationFunctions.h"
-#include "src/__support/FPUtil/bfloat16.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/nextdownbf16.h"
namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(bfloat16, nextdownbf16, (bfloat16 x)) {
- return fputil::nextupdown</*IsDown=*/true>(x);
+ return math::nextdownbf16(x);
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/nextdownf.cpp b/libc/src/math/generic/nextdownf.cpp
index 282ebfd139c67..86db31161cf8d 100644
--- a/libc/src/math/generic/nextdownf.cpp
+++ b/libc/src/math/generic/nextdownf.cpp
@@ -7,14 +7,10 @@
//===----------------------------------------------------------------------===//
#include "src/math/nextdownf.h"
-#include "src/__support/FPUtil/ManipulationFunctions.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/nextdownf.h"
namespace LIBC_NAMESPACE_DECL {
-LLVM_LIBC_FUNCTION(float, nextdownf, (float x)) {
- return fputil::nextupdown</*IsDown=*/true>(x);
-}
+LLVM_LIBC_FUNCTION(float, nextdownf, (float x)) { return math::nextdownf(x); }
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/nextdownf128.cpp b/libc/src/math/generic/nextdownf128.cpp
index 1557e3315be9b..3a9a60fe7130a 100644
--- a/libc/src/math/generic/nextdownf128.cpp
+++ b/libc/src/math/generic/nextdownf128.cpp
@@ -7,14 +7,12 @@
//===----------------------------------------------------------------------===//
#include "src/math/nextdownf128.h"
-#include "src/__support/FPUtil/ManipulationFunctions.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/nextdownf128.h"
namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(float128, nextdownf128, (float128 x)) {
- return fputil::nextupdown</*IsDown=*/true>(x);
+ return math::nextdownf128(x);
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/nextdownf16.cpp b/libc/src/math/generic/nextdownf16.cpp
index 2573fbf7267a6..0506b1b14757b 100644
--- a/libc/src/math/generic/nextdownf16.cpp
+++ b/libc/src/math/generic/nextdownf16.cpp
@@ -7,14 +7,12 @@
//===----------------------------------------------------------------------===//
#include "src/math/nextdownf16.h"
-#include "src/__support/FPUtil/ManipulationFunctions.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/nextdownf16.h"
namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(float16, nextdownf16, (float16 x)) {
- return fputil::nextupdown</*IsDown=*/true>(x);
+ return math::nextdownf16(x);
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/nextdownl.cpp b/libc/src/math/generic/nextdownl.cpp
index 476c5f30e66f9..35648aa291f0f 100644
--- a/libc/src/math/generic/nextdownl.cpp
+++ b/libc/src/math/generic/nextdownl.cpp
@@ -7,14 +7,12 @@
//===----------------------------------------------------------------------===//
#include "src/math/nextdownl.h"
-#include "src/__support/FPUtil/ManipulationFunctions.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/nextdownl.h"
namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(long double, nextdownl, (long double x)) {
- return fputil::nextupdown</*IsDown=*/true>(x);
+ return math::nextdownl(x);
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/test/shared/CMakeLists.txt b/libc/test/shared/CMakeLists.txt
index dfe2378269921..7a9f2f23a8074 100644
--- a/libc/test/shared/CMakeLists.txt
+++ b/libc/test/shared/CMakeLists.txt
@@ -112,6 +112,12 @@ add_fp_unittest(
libc.src.__support.math.llogbf16
libc.src.__support.math.logf16
libc.src.__support.math.llogbl
+ libc.src.__support.math.nextdown
+ libc.src.__support.math.nextdownbf16
+ libc.src.__support.math.nextdownf
+ libc.src.__support.math.nextdownf128
+ libc.src.__support.math.nextdownf16
+ libc.src.__support.math.nextdownl
libc.src.__support.math.pow
libc.src.__support.math.powf
libc.src.__support.math.rsqrtf
diff --git a/libc/test/shared/shared_math_test.cpp b/libc/test/shared/shared_math_test.cpp
index 8eba836538c41..f33f4f17a9e56 100644
--- a/libc/test/shared/shared_math_test.cpp
+++ b/libc/test/shared/shared_math_test.cpp
@@ -81,6 +81,8 @@ TEST(LlvmLibcSharedMathTest, AllFloat16) {
EXPECT_EQ(0, LIBC_NAMESPACE::shared::canonicalizef16(&canonicalizef16_cx,
&canonicalizef16_x));
EXPECT_FP_EQ(0x0p+0f16, canonicalizef16_cx);
+
+ EXPECT_FP_EQ(0x0p+0f16, LIBC_NAMESPACE::shared::nextdownf16(0.0f16));
}
#endif // LIBC_TYPES_HAS_FLOAT16
@@ -142,6 +144,8 @@ TEST(LlvmLibcSharedMathTest, AllFloat) {
EXPECT_EQ(0, LIBC_NAMESPACE::shared::canonicalizef(&canonicalizef_cx,
&canonicalizef_x));
EXPECT_FP_EQ(0x0p+0f, canonicalizef_cx);
+
+ EXPECT_FP_EQ(0x0p+0f, LIBC_NAMESPACE::shared::nextdownf(0.0f));
}
TEST(LlvmLibcSharedMathTest, AllDouble) {
@@ -179,6 +183,8 @@ TEST(LlvmLibcSharedMathTest, AllDouble) {
EXPECT_EQ(0, LIBC_NAMESPACE::shared::canonicalize(&canonicalize_cx,
&canonicalize_x));
EXPECT_FP_EQ(0.0, canonicalize_cx);
+
+ EXPECT_FP_EQ(0.0, LIBC_NAMESPACE::shared::nextdown(0.0));
}
TEST(LlvmLibcSharedMathTest, AllLongDouble) {
@@ -194,6 +200,8 @@ TEST(LlvmLibcSharedMathTest, AllLongDouble) {
EXPECT_EQ(0, LIBC_NAMESPACE::shared::canonicalizel(&canonicalizel_cx,
&canonicalizel_x));
EXPECT_FP_EQ(0x0p+0L, canonicalizel_cx);
+
+ EXPECT_FP_EQ(0x0p+0L, LIBC_NAMESPACE::shared::nextdownl(0.0L));
}
#ifdef LIBC_TYPES_HAS_FLOAT128
@@ -229,6 +237,9 @@ TEST(LlvmLibcSharedMathTest, AllFloat128) {
EXPECT_EQ(0, LIBC_NAMESPACE::shared::canonicalizef128(&canonicalizef128_cx,
&canonicalizef128_x));
EXPECT_FP_EQ(float128(0.0), canonicalizef128_cx);
+
+ EXPECT_FP_EQ(float128(0.0),
+ LIBC_NAMESPACE::shared::nextdownf128(float128(0.0)));
}
#endif // LIBC_TYPES_HAS_FLOAT128
@@ -245,4 +256,7 @@ TEST(LlvmLibcSharedMathTest, AllBFloat16) {
EXPECT_FP_EQ(bfloat16(5.0), LIBC_NAMESPACE::shared::bf16addf(2.0f, 3.0f));
EXPECT_FP_EQ(bfloat16(10.0),
LIBC_NAMESPACE::shared::bf16fmaf(2.0f, 3.0f, 4.0f));
+
+ EXPECT_FP_EQ(bfloat16(0.0),
+ LIBC_NAMESPACE::shared::nextdownbf16(bfloat16(0.0)));
}
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index a5b6823b9ca3d..071b34f7f6828 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -3168,6 +3168,63 @@ libc_support_library(
],
)
+libc_support_library(
+ name = "__support_math_nextdown",
+ hdrs = ["src/__support/math/nextdown.h"],
+ deps = [
+ ":__support_fputil_manipulation_functions",
+ ":__support_macros_config",
+ ],
+)
+
+libc_support_library(
+ name = "__support_math_nextdownbf16",
+ hdrs = ["src/__support/math/nextdownbf16.h"],
+ deps = [
+ ":__support_fputil_bfloat16",
+ ":__support_fputil_manipulation_functions",
+ ":__support_macros_config",
+ ],
+)
+
+libc_support_library(
+ name = "__support_math_nextdownf",
+ hdrs = ["src/__support/math/nextdownf.h"],
+ deps = [
+ ":__support_fputil_manipulation_functions",
+ ":__support_macros_config",
+ ],
+)
+
+libc_support_library(
+ name = "__support_math_nextdownf128",
+ hdrs = ["src/__support/math/nextdownf128.h"],
+ deps = [
+ ":__support_fputil_manipulation_functions",
+ ":__support_macros_properties_types",
+ ":llvm_libc_types_float128",
+ ],
+)
+
+libc_support_library(
+ name = "__support_math_nextdownf16",
+ hdrs = ["src/__support/math/nextdownf16.h"],
+ deps = [
+ ":__support_fputil_manipulation_functions",
+ ":__support_macros_config",
+ ":llvm_libc_macros_float16_macros",
+ ],
+)
+
+libc_support_library(
+ name = "__support_math_nextdownl",
+ hdrs = ["src/__support/math/nextdownl.h"],
+ deps = [
+ ":__support_fputil_manipulation_functions",
+ ":__support_macros_config",
+ ],
+)
+
libc_support_library(
name = "__support_math_ldexpf128",
hdrs = ["src/__support/math/ldexpf128.h"],
@@ -5416,15 +5473,40 @@ libc_math_function(name = "nextafterf128")
libc_math_function(name = "nextafterf16")
-libc_math_function(name = "nextdown")
+libc_math_function(
+ name = "nextdown",
+ additional_deps = [
+ ":__support_math_nextdown"
+ ],
+)
-libc_math_function(name = "nextdownf")
+libc_math_function(
+ name = "nextdownf",
+ additional_deps = [
+ ":__support_math_nextdownf"
+ ],
+)
-libc_math_function(name = "nextdownl")
+libc_math_function(
+ name = "nextdownl",
+ additional_deps = [
+ ":__support_math_nextdownl"
+ ],
+)
-libc_math_function(name = "nextdownf128")
+libc_math_function(
+ name = "nextdownf128",
+ additional_deps = [
+ ":__support_math_nextdownf128"
+ ],
+)
-libc_math_function(name = "nextdownf16")
+libc_math_function(
+ name = "nextdownf16",
+ additional_deps = [
+ ":__support_math_nextdownf16"
+ ],
+)
libc_math_function(name = "nexttoward")
>From 08a438edb8661337fbc95d6ec4badb8bd352e972 Mon Sep 17 00:00:00 2001
From: Ezzeldin Ibrahim <ezzibrahimx at gmail.com>
Date: Mon, 16 Feb 2026 17:16:54 +0200
Subject: [PATCH 2/4] fix tests
---
libc/test/shared/shared_math_test.cpp | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/libc/test/shared/shared_math_test.cpp b/libc/test/shared/shared_math_test.cpp
index f33f4f17a9e56..82ceec0912cf7 100644
--- a/libc/test/shared/shared_math_test.cpp
+++ b/libc/test/shared/shared_math_test.cpp
@@ -82,7 +82,8 @@ TEST(LlvmLibcSharedMathTest, AllFloat16) {
&canonicalizef16_x));
EXPECT_FP_EQ(0x0p+0f16, canonicalizef16_cx);
- EXPECT_FP_EQ(0x0p+0f16, LIBC_NAMESPACE::shared::nextdownf16(0.0f16));
+ EXPECT_FP_EQ(LIBC_NAMESPACE::shared::nextdownf16(0.0f16),
+ LIBC_NAMESPACE::shared::nextdownf16(0.0f16));
}
#endif // LIBC_TYPES_HAS_FLOAT16
@@ -145,7 +146,8 @@ TEST(LlvmLibcSharedMathTest, AllFloat) {
&canonicalizef_x));
EXPECT_FP_EQ(0x0p+0f, canonicalizef_cx);
- EXPECT_FP_EQ(0x0p+0f, LIBC_NAMESPACE::shared::nextdownf(0.0f));
+ EXPECT_FP_EQ(LIBC_NAMESPACE::shared::nextdownf(0.0f),
+ LIBC_NAMESPACE::shared::nextdownf(0.0f));
}
TEST(LlvmLibcSharedMathTest, AllDouble) {
@@ -184,7 +186,8 @@ TEST(LlvmLibcSharedMathTest, AllDouble) {
&canonicalize_x));
EXPECT_FP_EQ(0.0, canonicalize_cx);
- EXPECT_FP_EQ(0.0, LIBC_NAMESPACE::shared::nextdown(0.0));
+ EXPECT_FP_EQ(LIBC_NAMESPACE::shared::nextdown(0.0),
+ LIBC_NAMESPACE::shared::nextdown(0.0));
}
TEST(LlvmLibcSharedMathTest, AllLongDouble) {
@@ -201,7 +204,8 @@ TEST(LlvmLibcSharedMathTest, AllLongDouble) {
&canonicalizel_x));
EXPECT_FP_EQ(0x0p+0L, canonicalizel_cx);
- EXPECT_FP_EQ(0x0p+0L, LIBC_NAMESPACE::shared::nextdownl(0.0L));
+ EXPECT_FP_EQ(LIBC_NAMESPACE::shared::nextdownl(0.0L),
+ LIBC_NAMESPACE::shared::nextdownl(0.0L));
}
#ifdef LIBC_TYPES_HAS_FLOAT128
@@ -238,7 +242,7 @@ TEST(LlvmLibcSharedMathTest, AllFloat128) {
&canonicalizef128_x));
EXPECT_FP_EQ(float128(0.0), canonicalizef128_cx);
- EXPECT_FP_EQ(float128(0.0),
+ EXPECT_FP_EQ(LIBC_NAMESPACE::shared::nextdownf128(float128(0.0)),
LIBC_NAMESPACE::shared::nextdownf128(float128(0.0)));
}
@@ -257,6 +261,6 @@ TEST(LlvmLibcSharedMathTest, AllBFloat16) {
EXPECT_FP_EQ(bfloat16(10.0),
LIBC_NAMESPACE::shared::bf16fmaf(2.0f, 3.0f, 4.0f));
- EXPECT_FP_EQ(bfloat16(0.0),
+ EXPECT_FP_EQ(LIBC_NAMESPACE::shared::nextdownbf16(bfloat16(0.0)),
LIBC_NAMESPACE::shared::nextdownbf16(bfloat16(0.0)));
}
>From 4e9d448984dcf5f19b7bae9d157749e50346c247 Mon Sep 17 00:00:00 2001
From: Ezzeldin Ibrahim <ezzibrahimx at gmail.com>
Date: Mon, 16 Feb 2026 17:39:03 +0200
Subject: [PATCH 3/4] fix bazel formatting
---
utils/bazel/llvm-project-overlay/libc/BUILD.bazel | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index 071b34f7f6828..22d5bf4a46a95 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -5476,35 +5476,35 @@ libc_math_function(name = "nextafterf16")
libc_math_function(
name = "nextdown",
additional_deps = [
- ":__support_math_nextdown"
+ ":__support_math_nextdown",
],
)
libc_math_function(
name = "nextdownf",
additional_deps = [
- ":__support_math_nextdownf"
+ ":__support_math_nextdownf",
],
)
libc_math_function(
name = "nextdownl",
additional_deps = [
- ":__support_math_nextdownl"
+ ":__support_math_nextdownl",
],
)
libc_math_function(
name = "nextdownf128",
additional_deps = [
- ":__support_math_nextdownf128"
+ ":__support_math_nextdownf128",
],
)
libc_math_function(
name = "nextdownf16",
additional_deps = [
- ":__support_math_nextdownf16"
+ ":__support_math_nextdownf16",
],
)
>From ec445a77f07f43b97a74810d9861ead8e7a3fda5 Mon Sep 17 00:00:00 2001
From: Ezzeldin Ibrahim <ezzibrahimx at gmail.com>
Date: Tue, 17 Feb 2026 21:09:45 +0200
Subject: [PATCH 4/4] fix tests
---
libc/test/shared/CMakeLists.txt | 1 +
libc/test/shared/shared_math_test.cpp | 32 ++++++++++++++++++---------
2 files changed, 23 insertions(+), 10 deletions(-)
diff --git a/libc/test/shared/CMakeLists.txt b/libc/test/shared/CMakeLists.txt
index 7a9f2f23a8074..6f7919579328b 100644
--- a/libc/test/shared/CMakeLists.txt
+++ b/libc/test/shared/CMakeLists.txt
@@ -7,6 +7,7 @@ add_fp_unittest(
SRCS
shared_math_test.cpp
DEPENDS
+ libc.src.__support.FPUtil.fp_bits
libc.src.__support.math.acos
libc.src.__support.math.acosf
libc.src.__support.math.acosf16
diff --git a/libc/test/shared/shared_math_test.cpp b/libc/test/shared/shared_math_test.cpp
index 82ceec0912cf7..6bc7c11375233 100644
--- a/libc/test/shared/shared_math_test.cpp
+++ b/libc/test/shared/shared_math_test.cpp
@@ -13,8 +13,9 @@
#ifdef LIBC_TYPES_HAS_FLOAT16
TEST(LlvmLibcSharedMathTest, AllFloat16) {
- int exponent;
+ using FPBits = LIBC_NAMESPACE::fputil::FPBits<float16>;
+ int exponent;
EXPECT_FP_EQ(0x0p+0f16, LIBC_NAMESPACE::shared::acoshf16(1.0f16));
EXPECT_FP_EQ(0x0p+0f16, LIBC_NAMESPACE::shared::acospif16(1.0f16));
EXPECT_FP_EQ(0x1p+0f16, LIBC_NAMESPACE::shared::rsqrtf16(1.0f16));
@@ -82,13 +83,14 @@ TEST(LlvmLibcSharedMathTest, AllFloat16) {
&canonicalizef16_x));
EXPECT_FP_EQ(0x0p+0f16, canonicalizef16_cx);
- EXPECT_FP_EQ(LIBC_NAMESPACE::shared::nextdownf16(0.0f16),
- LIBC_NAMESPACE::shared::nextdownf16(0.0f16));
+ float16 neg_min_denormal = FPBits::min_subnormal(Sign ::NEG).get_val();
+ EXPECT_FP_EQ(neg_min_denormal, LIBC_NAMESPACE::shared::nextdownf16(0.0f16));
}
#endif // LIBC_TYPES_HAS_FLOAT16
TEST(LlvmLibcSharedMathTest, AllFloat) {
+ using FPBits = LIBC_NAMESPACE::fputil::FPBits<float>;
int exponent;
float sin, cos;
@@ -146,13 +148,16 @@ TEST(LlvmLibcSharedMathTest, AllFloat) {
&canonicalizef_x));
EXPECT_FP_EQ(0x0p+0f, canonicalizef_cx);
- EXPECT_FP_EQ(LIBC_NAMESPACE::shared::nextdownf(0.0f),
- LIBC_NAMESPACE::shared::nextdownf(0.0f));
+ float neg_min_denormal = FPBits::min_subnormal(Sign ::NEG).get_val();
+ EXPECT_FP_EQ(neg_min_denormal, LIBC_NAMESPACE::shared::nextdownf(0.0f));
}
TEST(LlvmLibcSharedMathTest, AllDouble) {
+ using FPBits = LIBC_NAMESPACE::fputil::FPBits<double>;
+
double sin, cos;
LIBC_NAMESPACE::shared::sincos(0.0, &sin, &cos);
+
EXPECT_FP_EQ(0x1.921fb54442d18p+0, LIBC_NAMESPACE::shared::acos(0.0));
EXPECT_FP_EQ(0x0p+0, LIBC_NAMESPACE::shared::asin(0.0));
EXPECT_FP_EQ(0x0p+0, LIBC_NAMESPACE::shared::atan(0.0));
@@ -186,11 +191,14 @@ TEST(LlvmLibcSharedMathTest, AllDouble) {
&canonicalize_x));
EXPECT_FP_EQ(0.0, canonicalize_cx);
- EXPECT_FP_EQ(LIBC_NAMESPACE::shared::nextdown(0.0),
+ double neg_min_denormal = FPBits::min_subnormal(Sign ::NEG).get_val();
+ EXPECT_FP_EQ(neg_min_denormal,
+
LIBC_NAMESPACE::shared::nextdown(0.0));
}
TEST(LlvmLibcSharedMathTest, AllLongDouble) {
+ using FPBits = LIBC_NAMESPACE::fputil::FPBits<long double>;
EXPECT_FP_EQ(0x0p+0L,
LIBC_NAMESPACE::shared::dfmal(0x0.p+0L, 0x0.p+0L, 0x0.p+0L));
EXPECT_FP_EQ(0x0p+0f, LIBC_NAMESPACE::shared::fsqrtl(0.0L));
@@ -204,13 +212,14 @@ TEST(LlvmLibcSharedMathTest, AllLongDouble) {
&canonicalizel_x));
EXPECT_FP_EQ(0x0p+0L, canonicalizel_cx);
- EXPECT_FP_EQ(LIBC_NAMESPACE::shared::nextdownl(0.0L),
- LIBC_NAMESPACE::shared::nextdownl(0.0L));
+ long double neg_min_denormal = FPBits::min_subnormal(Sign ::NEG).get_val();
+ EXPECT_FP_EQ(neg_min_denormal, LIBC_NAMESPACE::shared::nextdownl(0.0L));
}
#ifdef LIBC_TYPES_HAS_FLOAT128
TEST(LlvmLibcSharedMathTest, AllFloat128) {
+ using FPBits = LIBC_NAMESPACE::fputil::FPBits<float128>;
int exponent;
EXPECT_FP_EQ(float128(0x0p+0),
@@ -242,13 +251,15 @@ TEST(LlvmLibcSharedMathTest, AllFloat128) {
&canonicalizef128_x));
EXPECT_FP_EQ(float128(0.0), canonicalizef128_cx);
- EXPECT_FP_EQ(LIBC_NAMESPACE::shared::nextdownf128(float128(0.0)),
+ float128 neg_min_denormal = FPBits::min_subnormal(Sign ::NEG).get_val();
+ EXPECT_FP_EQ(neg_min_denormal,
LIBC_NAMESPACE::shared::nextdownf128(float128(0.0)));
}
#endif // LIBC_TYPES_HAS_FLOAT128
TEST(LlvmLibcSharedMathTest, AllBFloat16) {
+ using FPBits = LIBC_NAMESPACE::fputil::FPBits<bfloat16>;
EXPECT_FP_EQ(bfloat16(5.0), LIBC_NAMESPACE::shared::bf16add(2.0, 3.0));
EXPECT_FP_EQ(bfloat16(2.0f), LIBC_NAMESPACE::shared::bf16divf(4.0f, 2.0f));
@@ -261,6 +272,7 @@ TEST(LlvmLibcSharedMathTest, AllBFloat16) {
EXPECT_FP_EQ(bfloat16(10.0),
LIBC_NAMESPACE::shared::bf16fmaf(2.0f, 3.0f, 4.0f));
- EXPECT_FP_EQ(LIBC_NAMESPACE::shared::nextdownbf16(bfloat16(0.0)),
+ bfloat16 neg_min_denormal = FPBits::min_subnormal(Sign ::NEG).get_val();
+ EXPECT_FP_EQ(neg_min_denormal,
LIBC_NAMESPACE::shared::nextdownbf16(bfloat16(0.0)));
}
More information about the libc-commits
mailing list