[libc-commits] [libc] [llvm] [libc][math] Refactor fmaximum_mag_num family to header-only (PR #182169)
via libc-commits
libc-commits at lists.llvm.org
Sat Apr 25 14:58:00 PDT 2026
https://github.com/hulxv updated https://github.com/llvm/llvm-project/pull/182169
>From 265ae23ac59b2edac108ae23222f8968932ca4e7 Mon Sep 17 00:00:00 2001
From: hulxv <hulxxv at gmail.com>
Date: Thu, 19 Feb 2026 00:33:28 +0200
Subject: [PATCH 1/8] [libc][math] Refactor fmaximum_mag_num family to
header-only
Refactored functions:
- fmaximum_mag_num
- fmaximum_mag_numbf16
- fmaximum_mag_numf
---
libc/shared/math.h | 3 ++
libc/shared/math/fmaximum_mag_num.h | 22 ++++++++
libc/shared/math/fmaximum_mag_numbf16.h | 22 ++++++++
libc/shared/math/fmaximum_mag_numf.h | 22 ++++++++
libc/src/__support/math/CMakeLists.txt | 25 +++++++++
libc/src/__support/math/fmaximum_mag_num.h | 26 +++++++++
.../src/__support/math/fmaximum_mag_numbf16.h | 27 ++++++++++
libc/src/__support/math/fmaximum_mag_numf.h | 26 +++++++++
libc/src/math/generic/CMakeLists.txt | 11 ++--
libc/src/math/generic/fmaximum_mag_num.cpp | 6 +--
.../src/math/generic/fmaximum_mag_numbf16.cpp | 7 +--
libc/src/math/generic/fmaximum_mag_numf.cpp | 6 +--
libc/test/shared/CMakeLists.txt | 3 ++
libc/test/shared/shared_math_test.cpp | 7 +++
.../llvm-project-overlay/libc/BUILD.bazel | 54 ++++++++++++++++---
15 files changed, 239 insertions(+), 28 deletions(-)
create mode 100644 libc/shared/math/fmaximum_mag_num.h
create mode 100644 libc/shared/math/fmaximum_mag_numbf16.h
create mode 100644 libc/shared/math/fmaximum_mag_numf.h
create mode 100644 libc/src/__support/math/fmaximum_mag_num.h
create mode 100644 libc/src/__support/math/fmaximum_mag_numbf16.h
create mode 100644 libc/src/__support/math/fmaximum_mag_numf.h
diff --git a/libc/shared/math.h b/libc/shared/math.h
index 9192831afa3ba..9ac6174a1aa8a 100644
--- a/libc/shared/math.h
+++ b/libc/shared/math.h
@@ -172,6 +172,9 @@
#include "math/fmaxf.h"
#include "math/fmaxf128.h"
#include "math/fmaxf16.h"
+#include "math/fmaximum_mag_num.h"
+#include "math/fmaximum_mag_numbf16.h"
+#include "math/fmaximum_mag_numf.h"
#include "math/fmaxl.h"
#include "math/frexpf.h"
#include "math/frexpf128.h"
diff --git a/libc/shared/math/fmaximum_mag_num.h b/libc/shared/math/fmaximum_mag_num.h
new file mode 100644
index 0000000000000..f356682277b73
--- /dev/null
+++ b/libc/shared/math/fmaximum_mag_num.h
@@ -0,0 +1,22 @@
+//===-- Shared fmaximum_mag_num 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_FMAXIMUM_MAG_NUM_H
+#define LLVM_LIBC_SHARED_MATH_FMAXIMUM_MAG_NUM_H
+
+#include "src/__support/math/fmaximum_mag_num.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::fmaximum_mag_num;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_FMAXIMUM_MAG_NUM_H
diff --git a/libc/shared/math/fmaximum_mag_numbf16.h b/libc/shared/math/fmaximum_mag_numbf16.h
new file mode 100644
index 0000000000000..c650bd2902ac6
--- /dev/null
+++ b/libc/shared/math/fmaximum_mag_numbf16.h
@@ -0,0 +1,22 @@
+//===-- Shared fmaximum_mag_numbf16 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_FMAXIMUM_MAG_NUMBF16_H
+#define LLVM_LIBC_SHARED_MATH_FMAXIMUM_MAG_NUMBF16_H
+
+#include "src/__support/math/fmaximum_mag_numbf16.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::fmaximum_mag_numbf16;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_FMAXIMUM_MAG_NUMBF16_H
diff --git a/libc/shared/math/fmaximum_mag_numf.h b/libc/shared/math/fmaximum_mag_numf.h
new file mode 100644
index 0000000000000..862136f7db490
--- /dev/null
+++ b/libc/shared/math/fmaximum_mag_numf.h
@@ -0,0 +1,22 @@
+//===-- Shared fmaximum_mag_numf 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_FMAXIMUM_MAG_NUMF_H
+#define LLVM_LIBC_SHARED_MATH_FMAXIMUM_MAG_NUMF_H
+
+#include "src/__support/math/fmaximum_mag_numf.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::fmaximum_mag_numf;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_FMAXIMUM_MAG_NUMF_H
diff --git a/libc/src/__support/math/CMakeLists.txt b/libc/src/__support/math/CMakeLists.txt
index 095028c644d37..bc702879bd148 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -1645,6 +1645,31 @@ add_header_library(
libc.src.__support.FPUtil.fma
libc.src.__support.macros.config
)
+add_header_library(
+ fmaximum_mag_num
+ HDRS
+ fmaximum_mag_num.h
+ DEPENDS
+ libc.src.__support.FPUtil.basic_operations
+ libc.src.__support.macros.config
+)
+add_header_library(
+ fmaximum_mag_numbf16
+ HDRS
+ fmaximum_mag_numbf16.h
+ DEPENDS
+ libc.src.__support.FPUtil.basic_operations
+ libc.src.__support.FPUtil.bfloat16
+ libc.src.__support.macros.config
+)
+add_header_library(
+ fmaximum_mag_numf
+ HDRS
+ fmaximum_mag_numf.h
+ DEPENDS
+ libc.src.__support.FPUtil.basic_operations
+ libc.src.__support.macros.config
+)
add_header_library(
fmabf16
diff --git a/libc/src/__support/math/fmaximum_mag_num.h b/libc/src/__support/math/fmaximum_mag_num.h
new file mode 100644
index 0000000000000..b69effd9dfbd7
--- /dev/null
+++ b/libc/src/__support/math/fmaximum_mag_num.h
@@ -0,0 +1,26 @@
+//===-- Implementation header for fmaximum_mag_num --------------*- 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_FMAXIMUM_MAG_NUM_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_FMAXIMUM_MAG_NUM_H
+
+#include "src/__support/FPUtil/BasicOperations.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+LIBC_INLINE double fmaximum_mag_num(double x, double y) {
+ return fputil::fmaximum_mag_num(x, y);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_FMAXIMUM_MAG_NUM_H
diff --git a/libc/src/__support/math/fmaximum_mag_numbf16.h b/libc/src/__support/math/fmaximum_mag_numbf16.h
new file mode 100644
index 0000000000000..aa87054f44c90
--- /dev/null
+++ b/libc/src/__support/math/fmaximum_mag_numbf16.h
@@ -0,0 +1,27 @@
+//===-- Implementation header for fmaximum_mag_numbf16 ----------*- 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_FMAXIMUM_MAG_NUMBF16_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_FMAXIMUM_MAG_NUMBF16_H
+
+#include "src/__support/FPUtil/BasicOperations.h"
+#include "src/__support/FPUtil/bfloat16.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+LIBC_INLINE bfloat16 fmaximum_mag_numbf16(bfloat16 x, bfloat16 y) {
+ return fputil::fmaximum_mag_num(x, y);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_FMAXIMUM_MAG_NUMBF16_H
diff --git a/libc/src/__support/math/fmaximum_mag_numf.h b/libc/src/__support/math/fmaximum_mag_numf.h
new file mode 100644
index 0000000000000..155b220049fd3
--- /dev/null
+++ b/libc/src/__support/math/fmaximum_mag_numf.h
@@ -0,0 +1,26 @@
+//===-- Implementation header for fmaximum_mag_numf -------------*- 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_FMAXIMUM_MAG_NUMF_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_FMAXIMUM_MAG_NUMF_H
+
+#include "src/__support/FPUtil/BasicOperations.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+LIBC_INLINE float fmaximum_mag_numf(float x, float y) {
+ return fputil::fmaximum_mag_num(x, y);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_FMAXIMUM_MAG_NUMF_H
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index ff02cdec1ba0f..e59306fcb970c 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -2423,7 +2423,7 @@ add_entrypoint_object(
HDRS
../fmaximum_mag_num.h
DEPENDS
- libc.src.__support.FPUtil.basic_operations
+ libc.src.__support.math.fmaximum_mag_num
)
add_entrypoint_object(
@@ -2433,7 +2433,7 @@ add_entrypoint_object(
HDRS
../fmaximum_mag_numf.h
DEPENDS
- libc.src.__support.FPUtil.basic_operations
+ libc.src.__support.math.fmaximum_mag_numf
)
add_entrypoint_object(
@@ -2475,12 +2475,7 @@ add_entrypoint_object(
HDRS
../fmaximum_mag_numbf16.h
DEPENDS
- libc.src.__support.FPUtil.basic_operations
- libc.src.__support.FPUtil.bfloat16
- libc.src.__support.macros.config
- libc.src.__support.macros.properties.types
- FLAGS
- MISC_MATH_BASIC_OPS_OPT
+ libc.src.__support.math.fmaximum_mag_numbf16
)
add_entrypoint_object(
diff --git a/libc/src/math/generic/fmaximum_mag_num.cpp b/libc/src/math/generic/fmaximum_mag_num.cpp
index de250bbd32b7b..40c8f6e3755d0 100644
--- a/libc/src/math/generic/fmaximum_mag_num.cpp
+++ b/libc/src/math/generic/fmaximum_mag_num.cpp
@@ -7,14 +7,12 @@
//===----------------------------------------------------------------------===//
#include "src/math/fmaximum_mag_num.h"
-#include "src/__support/FPUtil/BasicOperations.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/fmaximum_mag_num.h"
namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(double, fmaximum_mag_num, (double x, double y)) {
- return fputil::fmaximum_mag_num(x, y);
+ return math::fmaximum_mag_num(x, y);
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/fmaximum_mag_numbf16.cpp b/libc/src/math/generic/fmaximum_mag_numbf16.cpp
index 485e32959b53a..a54725b7f1eee 100644
--- a/libc/src/math/generic/fmaximum_mag_numbf16.cpp
+++ b/libc/src/math/generic/fmaximum_mag_numbf16.cpp
@@ -7,15 +7,12 @@
//===----------------------------------------------------------------------===//
#include "src/math/fmaximum_mag_numbf16.h"
-#include "src/__support/FPUtil/BasicOperations.h"
-#include "src/__support/FPUtil/bfloat16.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/fmaximum_mag_numbf16.h"
namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(bfloat16, fmaximum_mag_numbf16, (bfloat16 x, bfloat16 y)) {
- return fputil::fmaximum_mag_num(x, y);
+ return math::fmaximum_mag_numbf16(x, y);
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/fmaximum_mag_numf.cpp b/libc/src/math/generic/fmaximum_mag_numf.cpp
index e372f1bd1f9d3..97039ef845aec 100644
--- a/libc/src/math/generic/fmaximum_mag_numf.cpp
+++ b/libc/src/math/generic/fmaximum_mag_numf.cpp
@@ -7,14 +7,12 @@
//===----------------------------------------------------------------------===//
#include "src/math/fmaximum_mag_numf.h"
-#include "src/__support/FPUtil/BasicOperations.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/fmaximum_mag_numf.h"
namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(float, fmaximum_mag_numf, (float x, float y)) {
- return fputil::fmaximum_mag_num(x, y);
+ return math::fmaximum_mag_numf(x, y);
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/test/shared/CMakeLists.txt b/libc/test/shared/CMakeLists.txt
index 0aad310113780..01884e8d52430 100644
--- a/libc/test/shared/CMakeLists.txt
+++ b/libc/test/shared/CMakeLists.txt
@@ -169,6 +169,9 @@ add_fp_unittest(
libc.src.__support.math.fmaxf
libc.src.__support.math.fmaxf128
libc.src.__support.math.fmaxf16
+ libc.src.__support.math.fmaximum_mag_num
+ libc.src.__support.math.fmaximum_mag_numbf16
+ libc.src.__support.math.fmaximum_mag_numf
libc.src.__support.math.fmaxl
libc.src.__support.math.frexpf
libc.src.__support.math.frexpf128
diff --git a/libc/test/shared/shared_math_test.cpp b/libc/test/shared/shared_math_test.cpp
index 7241f4fd37324..81ba675c1e71a 100644
--- a/libc/test/shared/shared_math_test.cpp
+++ b/libc/test/shared/shared_math_test.cpp
@@ -182,6 +182,8 @@ TEST(LlvmLibcSharedMathTest, AllFloat) {
EXPECT_FP_EQ(0.0f, LIBC_NAMESPACE::shared::fdimf(0.0f, 0.0f));
EXPECT_FP_EQ(0.0f, LIBC_NAMESPACE::shared::floorf(0.0f));
EXPECT_FP_EQ(0.0f, LIBC_NAMESPACE::shared::fmaxf(0.0f, 0.0f));
+ EXPECT_FP_EQ(0x0p+0f, LIBC_NAMESPACE::shared::fmaximum_mag_numf(0.0f, 0.0f));
+
float getpayloadf_x = 0.0f;
EXPECT_FP_EQ(-1.0f, LIBC_NAMESPACE::shared::getpayloadf(&getpayloadf_x));
@@ -266,6 +268,8 @@ TEST(LlvmLibcSharedMathTest, AllDouble) {
EXPECT_FP_EQ(0.0, LIBC_NAMESPACE::shared::fdim(0.0, 0.0));
EXPECT_FP_EQ(0.0, LIBC_NAMESPACE::shared::floor(0.0));
EXPECT_FP_EQ(0.0, LIBC_NAMESPACE::shared::fmax(0.0, 0.0));
+ EXPECT_FP_EQ(0.0, LIBC_NAMESPACE::shared::fmaximum_mag_num(0.0, 0.0));
+
double getpayload_x = 0.0;
EXPECT_FP_EQ(-1.0, LIBC_NAMESPACE::shared::getpayload(&getpayload_x));
@@ -492,6 +496,9 @@ TEST(LlvmLibcSharedMathTest, AllBFloat16) {
EXPECT_FP_EQ(bfloat16(0.0),
LIBC_NAMESPACE::shared::fmaxbf16(bfloat16(0.0), bfloat16(0.0)));
+ EXPECT_FP_EQ(0.0f, LIBC_NAMESPACE::shared::fmaximum_mag_numbf16(
+ bfloat16(0.0), bfloat16(0.0)));
+
bfloat16 getpayloadbf16_x = bfloat16(0.0);
EXPECT_FP_EQ(bfloat16(-1.0),
LIBC_NAMESPACE::shared::getpayloadbf16(&getpayloadbf16_x));
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index 9d1f4f9e6a493..28fb6786fc613 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -4756,12 +4756,39 @@ libc_support_library(
],
)
+libc_support_library(
+ name = "__support_math_fmaximum_mag_num",
+ hdrs = ["src/__support/math/fmaximum_mag_num.h"],
+ deps = [
+ ":__support_fputil_basic_operations",
+ ":__support_macros_config",
+ ],
+)
+
+libc_support_library(
+ name = "__support_math_fmaximum_mag_numbf16",
+ hdrs = ["src/__support/math/fmaximum_mag_numbf16.h"],
+ deps = [
+ ":__support_fputil_basic_operations",
+ ":__support_fputil_bfloat16",
+ ":__support_macros_config",
+ ],
+)
+
+libc_support_library(
+ name = "__support_math_fmaximum_mag_numf",
+ hdrs = ["src/__support/math/fmaximum_mag_numf.h"],
+ deps = [
+ ":__support_fputil_basic_operations",
+ ":__support_macros_config",
+ ],
+)
+
libc_support_library(
name = "__support_math_fmaxf",
hdrs = ["src/__support/math/fmaxf.h"],
deps = [
":__support_fputil_basic_operations",
- ":__support_macros_config",
],
)
@@ -4789,10 +4816,6 @@ libc_support_library(
name = "__support_math_fmaxl",
hdrs = ["src/__support/math/fmaxl.h"],
deps = [
- ":__support_fputil_basic_operations",
- ":__support_macros_config",
- ],
-)
libc_support_library(
name = "__support_math_ffmal",
@@ -7884,9 +7907,26 @@ libc_math_function(
name = "fmaximum_magf16",
)
-libc_math_function(name = "fmaximum_mag_num")
+libc_math_function(
+ name = "fmaximum_mag_num",
+ additional_deps = [
+ ":__support_math_fmaximum_mag_num",
+ ],
+)
+
+libc_math_function(
+ name = "fmaximum_mag_numbf16",
+ additional_deps = [
+ ":__support_math_fmaximum_mag_numbf16",
+ ],
+)
-libc_math_function(name = "fmaximum_mag_numf")
+libc_math_function(
+ name = "fmaximum_mag_numf",
+ additional_deps = [
+ ":__support_math_fmaximum_mag_numf",
+ ],
+)
libc_math_function(name = "fmaximum_mag_numl")
>From 1409d1ebd6fd3060bb577efe6baefe2275aace6f Mon Sep 17 00:00:00 2001
From: hulxv <hulxxv at gmail.com>
Date: Wed, 4 Mar 2026 03:50:57 +0200
Subject: [PATCH 2/8] fix: format
---
libc/test/shared/shared_math_test.cpp | 5 +++
.../llvm-project-overlay/libc/BUILD.bazel | 39 +++++++++++--------
2 files changed, 27 insertions(+), 17 deletions(-)
diff --git a/libc/test/shared/shared_math_test.cpp b/libc/test/shared/shared_math_test.cpp
index 81ba675c1e71a..0c411361482ae 100644
--- a/libc/test/shared/shared_math_test.cpp
+++ b/libc/test/shared/shared_math_test.cpp
@@ -482,6 +482,11 @@ TEST(LlvmLibcSharedMathTest, AllBFloat16) {
EXPECT_EQ(0, LIBC_NAMESPACE::shared::canonicalizebf16(&canonicalizebf16_cx,
&canonicalizebf16_x));
EXPECT_FP_EQ(bfloat16(0.0), canonicalizebf16_cx);
+ EXPECT_FP_EQ(bfloat16(5.0), LIBC_NAMESPACE::shared::bf16addf(2.0f, 3.0f));
+ EXPECT_FP_EQ(bfloat16(5.0), LIBC_NAMESPACE::shared::bf16addl(2L, 3L));
+ 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::cbrtbf16(bfloat16(0.0)));
EXPECT_FP_EQ(bfloat16(0.0), LIBC_NAMESPACE::shared::ceilbf16(bfloat16(0.0)));
EXPECT_FP_EQ(bfloat16(0.0), LIBC_NAMESPACE::shared::copysignbf16(
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index 28fb6786fc613..2dbde19166d83 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -4757,8 +4757,8 @@ libc_support_library(
)
libc_support_library(
- name = "__support_math_fmaximum_mag_num",
- hdrs = ["src/__support/math/fmaximum_mag_num.h"],
+ name = "__support_math_fmaxf",
+ hdrs = ["src/__support/math/fmaxf.h"],
deps = [
":__support_fputil_basic_operations",
":__support_macros_config",
@@ -4766,56 +4766,61 @@ libc_support_library(
)
libc_support_library(
- name = "__support_math_fmaximum_mag_numbf16",
- hdrs = ["src/__support/math/fmaximum_mag_numbf16.h"],
+ name = "__support_math_fmaxf128",
+ hdrs = ["src/__support/math/fmaxf128.h"],
deps = [
":__support_fputil_basic_operations",
- ":__support_fputil_bfloat16",
":__support_macros_config",
+ ":llvm_libc_types_float128",
],
)
libc_support_library(
- name = "__support_math_fmaximum_mag_numf",
- hdrs = ["src/__support/math/fmaximum_mag_numf.h"],
+ name = "__support_math_fmaxf16",
+ hdrs = ["src/__support/math/fmaxf16.h"],
deps = [
":__support_fputil_basic_operations",
":__support_macros_config",
+ ":llvm_libc_macros_float16_macros",
],
)
libc_support_library(
- name = "__support_math_fmaxf",
- hdrs = ["src/__support/math/fmaxf.h"],
+ name = "__support_math_fmaxl",
+ hdrs = ["src/__support/math/fmaxl.h"],
deps = [
":__support_fputil_basic_operations",
+ ":__support_macros_config",
],
)
libc_support_library(
- name = "__support_math_fmaxf128",
- hdrs = ["src/__support/math/fmaxf128.h"],
+ name = "__support_math_fmaximum_mag_num",
+ hdrs = ["src/__support/math/fmaximum_mag_num.h"],
deps = [
":__support_fputil_basic_operations",
":__support_macros_config",
- ":llvm_libc_types_float128",
],
)
libc_support_library(
- name = "__support_math_fmaxf16",
- hdrs = ["src/__support/math/fmaxf16.h"],
+ name = "__support_math_fmaximum_mag_numbf16",
+ hdrs = ["src/__support/math/fmaximum_mag_numbf16.h"],
deps = [
":__support_fputil_basic_operations",
+ ":__support_fputil_bfloat16",
":__support_macros_config",
- ":llvm_libc_macros_float16_macros",
],
)
libc_support_library(
- name = "__support_math_fmaxl",
- hdrs = ["src/__support/math/fmaxl.h"],
+ name = "__support_math_fmaximum_mag_numf",
+ hdrs = ["src/__support/math/fmaximum_mag_numf.h"],
deps = [
+ ":__support_fputil_basic_operations",
+ ":__support_macros_config",
+ ],
+)
libc_support_library(
name = "__support_math_ffmal",
>From 9d5be6cb103b9c2fede99cda84eb0efff0fbc25a Mon Sep 17 00:00:00 2001
From: hulxv <hulxxv at gmail.com>
Date: Sat, 14 Mar 2026 02:21:29 +0200
Subject: [PATCH 3/8] fix
---
libc/shared/math/fmaximum_mag_num.h | 1 +
libc/shared/math/fmaximum_mag_numbf16.h | 1 +
libc/shared/math/fmaximum_mag_numf.h | 1 +
libc/src/__support/math/CMakeLists.txt | 3 +++
libc/src/__support/math/fmaximum_mag_num.h | 1 -
libc/src/__support/math/fmaximum_mag_numbf16.h | 1 -
libc/src/__support/math/fmaximum_mag_numf.h | 1 -
7 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/libc/shared/math/fmaximum_mag_num.h b/libc/shared/math/fmaximum_mag_num.h
index f356682277b73..a644072cd4406 100644
--- a/libc/shared/math/fmaximum_mag_num.h
+++ b/libc/shared/math/fmaximum_mag_num.h
@@ -9,6 +9,7 @@
#ifndef LLVM_LIBC_SHARED_MATH_FMAXIMUM_MAG_NUM_H
#define LLVM_LIBC_SHARED_MATH_FMAXIMUM_MAG_NUM_H
+#include "shared/libc_common.h"
#include "src/__support/math/fmaximum_mag_num.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/shared/math/fmaximum_mag_numbf16.h b/libc/shared/math/fmaximum_mag_numbf16.h
index c650bd2902ac6..d6b4067e59451 100644
--- a/libc/shared/math/fmaximum_mag_numbf16.h
+++ b/libc/shared/math/fmaximum_mag_numbf16.h
@@ -9,6 +9,7 @@
#ifndef LLVM_LIBC_SHARED_MATH_FMAXIMUM_MAG_NUMBF16_H
#define LLVM_LIBC_SHARED_MATH_FMAXIMUM_MAG_NUMBF16_H
+#include "shared/libc_common.h"
#include "src/__support/math/fmaximum_mag_numbf16.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/shared/math/fmaximum_mag_numf.h b/libc/shared/math/fmaximum_mag_numf.h
index 862136f7db490..57236f4dcf1d9 100644
--- a/libc/shared/math/fmaximum_mag_numf.h
+++ b/libc/shared/math/fmaximum_mag_numf.h
@@ -9,6 +9,7 @@
#ifndef LLVM_LIBC_SHARED_MATH_FMAXIMUM_MAG_NUMF_H
#define LLVM_LIBC_SHARED_MATH_FMAXIMUM_MAG_NUMF_H
+#include "shared/libc_common.h"
#include "src/__support/math/fmaximum_mag_numf.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/__support/math/CMakeLists.txt b/libc/src/__support/math/CMakeLists.txt
index bc702879bd148..d6c8ac2b96710 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -1645,6 +1645,7 @@ add_header_library(
libc.src.__support.FPUtil.fma
libc.src.__support.macros.config
)
+
add_header_library(
fmaximum_mag_num
HDRS
@@ -1653,6 +1654,7 @@ add_header_library(
libc.src.__support.FPUtil.basic_operations
libc.src.__support.macros.config
)
+
add_header_library(
fmaximum_mag_numbf16
HDRS
@@ -1662,6 +1664,7 @@ add_header_library(
libc.src.__support.FPUtil.bfloat16
libc.src.__support.macros.config
)
+
add_header_library(
fmaximum_mag_numf
HDRS
diff --git a/libc/src/__support/math/fmaximum_mag_num.h b/libc/src/__support/math/fmaximum_mag_num.h
index b69effd9dfbd7..2d05351c7fdb0 100644
--- a/libc/src/__support/math/fmaximum_mag_num.h
+++ b/libc/src/__support/math/fmaximum_mag_num.h
@@ -13,7 +13,6 @@
#include "src/__support/macros/config.h"
namespace LIBC_NAMESPACE_DECL {
-
namespace math {
LIBC_INLINE double fmaximum_mag_num(double x, double y) {
diff --git a/libc/src/__support/math/fmaximum_mag_numbf16.h b/libc/src/__support/math/fmaximum_mag_numbf16.h
index aa87054f44c90..b459f469dc790 100644
--- a/libc/src/__support/math/fmaximum_mag_numbf16.h
+++ b/libc/src/__support/math/fmaximum_mag_numbf16.h
@@ -14,7 +14,6 @@
#include "src/__support/macros/config.h"
namespace LIBC_NAMESPACE_DECL {
-
namespace math {
LIBC_INLINE bfloat16 fmaximum_mag_numbf16(bfloat16 x, bfloat16 y) {
diff --git a/libc/src/__support/math/fmaximum_mag_numf.h b/libc/src/__support/math/fmaximum_mag_numf.h
index 155b220049fd3..d00243e295947 100644
--- a/libc/src/__support/math/fmaximum_mag_numf.h
+++ b/libc/src/__support/math/fmaximum_mag_numf.h
@@ -13,7 +13,6 @@
#include "src/__support/macros/config.h"
namespace LIBC_NAMESPACE_DECL {
-
namespace math {
LIBC_INLINE float fmaximum_mag_numf(float x, float y) {
>From 90c5be59dc40fe76d4f037f874b1846486c5f69d Mon Sep 17 00:00:00 2001
From: hulxv <hulxxv at gmail.com>
Date: Wed, 18 Mar 2026 01:27:32 +0200
Subject: [PATCH 4/8] missed `MISC_MATH_BASIC_OPS_OPT`
---
libc/src/__support/math/CMakeLists.txt | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/libc/src/__support/math/CMakeLists.txt b/libc/src/__support/math/CMakeLists.txt
index d6c8ac2b96710..d4a8caf240a3e 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -1653,6 +1653,8 @@ add_header_library(
DEPENDS
libc.src.__support.FPUtil.basic_operations
libc.src.__support.macros.config
+ FLAGS
+ MISC_MATH_BASIC_OPS_OPT
)
add_header_library(
@@ -1663,6 +1665,8 @@ add_header_library(
libc.src.__support.FPUtil.basic_operations
libc.src.__support.FPUtil.bfloat16
libc.src.__support.macros.config
+ FLAGS
+ MISC_MATH_BASIC_OPS_OPT
)
add_header_library(
@@ -1672,6 +1676,8 @@ add_header_library(
DEPENDS
libc.src.__support.FPUtil.basic_operations
libc.src.__support.macros.config
+ FLAGS
+ MISC_MATH_BASIC_OPS_OPT
)
add_header_library(
>From b37a96ae3ac3a2553d5d8b61c2861bcae827a546 Mon Sep 17 00:00:00 2001
From: hulxv <hulxxv at gmail.com>
Date: Wed, 22 Apr 2026 23:19:32 +0200
Subject: [PATCH 5/8] fix the ci
---
libc/test/shared/shared_math_test.cpp | 4 ----
1 file changed, 4 deletions(-)
diff --git a/libc/test/shared/shared_math_test.cpp b/libc/test/shared/shared_math_test.cpp
index 0c411361482ae..ccbc869abf5e6 100644
--- a/libc/test/shared/shared_math_test.cpp
+++ b/libc/test/shared/shared_math_test.cpp
@@ -482,10 +482,6 @@ TEST(LlvmLibcSharedMathTest, AllBFloat16) {
EXPECT_EQ(0, LIBC_NAMESPACE::shared::canonicalizebf16(&canonicalizebf16_cx,
&canonicalizebf16_x));
EXPECT_FP_EQ(bfloat16(0.0), canonicalizebf16_cx);
- EXPECT_FP_EQ(bfloat16(5.0), LIBC_NAMESPACE::shared::bf16addf(2.0f, 3.0f));
- EXPECT_FP_EQ(bfloat16(5.0), LIBC_NAMESPACE::shared::bf16addl(2L, 3L));
- 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::cbrtbf16(bfloat16(0.0)));
EXPECT_FP_EQ(bfloat16(0.0), LIBC_NAMESPACE::shared::ceilbf16(bfloat16(0.0)));
>From 6934e02db2472574b8a5fdfec30823498bc2c4bb Mon Sep 17 00:00:00 2001
From: hulxv <hulxxv at gmail.com>
Date: Wed, 22 Apr 2026 23:23:20 +0200
Subject: [PATCH 6/8] constexpr
---
libc/src/__support/FPUtil/BasicOperations.h | 21 ++++++++++++-------
libc/src/__support/math/fmaximum_mag_num.h | 2 +-
.../src/__support/math/fmaximum_mag_numbf16.h | 2 +-
libc/src/__support/math/fmaximum_mag_numf.h | 2 +-
libc/test/shared/CMakeLists.txt | 3 +++
.../shared/shared_math_constexpr_test.cpp | 5 +++++
6 files changed, 25 insertions(+), 10 deletions(-)
diff --git a/libc/src/__support/FPUtil/BasicOperations.h b/libc/src/__support/FPUtil/BasicOperations.h
index ee5c90a8f290f..d4e53b65ee3c6 100644
--- a/libc/src/__support/FPUtil/BasicOperations.h
+++ b/libc/src/__support/FPUtil/BasicOperations.h
@@ -33,7 +33,8 @@ LIBC_INLINE constexpr T abs(T x) {
namespace internal {
template <typename T>
-LIBC_INLINE cpp::enable_if_t<cpp::is_floating_point_v<T>, T> max(T x, T y) {
+LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_floating_point_v<T>, T>
+max(T x, T y) {
FPBits<T> x_bits(x);
FPBits<T> y_bits(y);
@@ -47,11 +48,17 @@ LIBC_INLINE cpp::enable_if_t<cpp::is_floating_point_v<T>, T> max(T x, T y) {
#ifdef LIBC_TYPES_HAS_FLOAT16
#if defined(__LIBC_USE_BUILTIN_FMAXF16_FMINF16)
-template <> LIBC_INLINE float16 max(float16 x, float16 y) {
+template <> LIBC_INLINE constexpr float16 max(float16 x, float16 y) {
+ if (cpp::is_constant_evaluated()) {
+ FPBits<float16> x_bits(x), y_bits(y);
+ if (x_bits.sign() != y_bits.sign())
+ return x_bits.is_pos() ? x : y;
+ return x > y ? x : y;
+ }
return __builtin_fmaxf16(x, y);
}
#elif !defined(LIBC_TARGET_ARCH_IS_AARCH64)
-template <> LIBC_INLINE float16 max(float16 x, float16 y) {
+template <> LIBC_INLINE constexpr float16 max(float16 x, float16 y) {
FPBits<float16> x_bits(x);
FPBits<float16> y_bits(y);
@@ -63,11 +70,11 @@ template <> LIBC_INLINE float16 max(float16 x, float16 y) {
#endif // LIBC_TYPES_HAS_FLOAT16
#if defined(__LIBC_USE_BUILTIN_FMAX_FMIN) && !defined(LIBC_TARGET_ARCH_IS_X86)
-template <> LIBC_INLINE float max(float x, float y) {
+template <> LIBC_INLINE constexpr float max(float x, float y) {
return __builtin_fmaxf(x, y);
}
-template <> LIBC_INLINE double max(double x, double y) {
+template <> LIBC_INLINE constexpr double max(double x, double y) {
return __builtin_fmax(x, y);
}
#endif
@@ -159,7 +166,7 @@ LIBC_INLINE T fminimum(T x, T y) {
}
template <typename T, cpp::enable_if_t<cpp::is_floating_point_v<T>, int> = 0>
-LIBC_INLINE T fmaximum_num(T x, T y) {
+LIBC_INLINE constexpr T fmaximum_num(T x, T y) {
FPBits<T> bitx(x), bity(y);
if (bitx.is_signaling_nan() || bity.is_signaling_nan()) {
fputil::raise_except_if_required(FE_INVALID);
@@ -211,7 +218,7 @@ LIBC_INLINE T fminimum_mag(T x, T y) {
}
template <typename T, cpp::enable_if_t<cpp::is_floating_point_v<T>, int> = 0>
-LIBC_INLINE T fmaximum_mag_num(T x, T y) {
+LIBC_INLINE constexpr T fmaximum_mag_num(T x, T y) {
FPBits<T> bitx(x), bity(y);
if (abs(x) > abs(y))
diff --git a/libc/src/__support/math/fmaximum_mag_num.h b/libc/src/__support/math/fmaximum_mag_num.h
index 2d05351c7fdb0..bb54f5c8919d1 100644
--- a/libc/src/__support/math/fmaximum_mag_num.h
+++ b/libc/src/__support/math/fmaximum_mag_num.h
@@ -15,7 +15,7 @@
namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE double fmaximum_mag_num(double x, double y) {
+LIBC_INLINE constexpr double fmaximum_mag_num(double x, double y) {
return fputil::fmaximum_mag_num(x, y);
}
diff --git a/libc/src/__support/math/fmaximum_mag_numbf16.h b/libc/src/__support/math/fmaximum_mag_numbf16.h
index b459f469dc790..7010371015589 100644
--- a/libc/src/__support/math/fmaximum_mag_numbf16.h
+++ b/libc/src/__support/math/fmaximum_mag_numbf16.h
@@ -16,7 +16,7 @@
namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE bfloat16 fmaximum_mag_numbf16(bfloat16 x, bfloat16 y) {
+LIBC_INLINE constexpr bfloat16 fmaximum_mag_numbf16(bfloat16 x, bfloat16 y) {
return fputil::fmaximum_mag_num(x, y);
}
diff --git a/libc/src/__support/math/fmaximum_mag_numf.h b/libc/src/__support/math/fmaximum_mag_numf.h
index d00243e295947..c2298b85b4c77 100644
--- a/libc/src/__support/math/fmaximum_mag_numf.h
+++ b/libc/src/__support/math/fmaximum_mag_numf.h
@@ -15,7 +15,7 @@
namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE float fmaximum_mag_numf(float x, float y) {
+LIBC_INLINE constexpr float fmaximum_mag_numf(float x, float y) {
return fputil::fmaximum_mag_num(x, y);
}
diff --git a/libc/test/shared/CMakeLists.txt b/libc/test/shared/CMakeLists.txt
index 01884e8d52430..a13f9daabcf99 100644
--- a/libc/test/shared/CMakeLists.txt
+++ b/libc/test/shared/CMakeLists.txt
@@ -321,6 +321,9 @@ add_fp_unittest(
libc.src.__support.math.fabsf128
libc.src.__support.math.fabsf16
libc.src.__support.math.fabsl
+ libc.src.__support.math.fmaximum_mag_num
+ libc.src.__support.math.fmaximum_mag_numbf16
+ libc.src.__support.math.fmaximum_mag_numf
libc.src.__support.math.log
libc.src.__support.math.logbbf16
)
diff --git a/libc/test/shared/shared_math_constexpr_test.cpp b/libc/test/shared/shared_math_constexpr_test.cpp
index e9dbdd3740846..216aef14b5c5e 100644
--- a/libc/test/shared/shared_math_constexpr_test.cpp
+++ b/libc/test/shared/shared_math_constexpr_test.cpp
@@ -18,6 +18,7 @@
static_assert(0.0 == LIBC_NAMESPACE::shared::ceil(0.0));
static_assert(0.0 == LIBC_NAMESPACE::shared::copysign(0.0, 0.0));
static_assert(1.0 == LIBC_NAMESPACE::shared::fabs(-1.0));
+static_assert(2.0 == LIBC_NAMESPACE::shared::fmaximum_mag_num(1.0, 2.0));
static_assert(1.0 == LIBC_NAMESPACE::shared::floor(1.2));
static_assert(0.0 == LIBC_NAMESPACE::shared::log(1.0));
@@ -28,6 +29,7 @@ static_assert(0.0 == LIBC_NAMESPACE::shared::log(1.0));
static_assert(0.0f == LIBC_NAMESPACE::shared::ceilf(0.0f));
static_assert(0.0f == LIBC_NAMESPACE::shared::copysignf(0.0f, 0.0f));
static_assert(1.0f == LIBC_NAMESPACE::shared::fabsf(-1.0f));
+static_assert(2.0f == LIBC_NAMESPACE::shared::fmaximum_mag_numf(1.0f, 2.0f));
static_assert(0.0f == LIBC_NAMESPACE::shared::floorf(0.0f));
//===----------------------------------------------------------------------===//
@@ -88,6 +90,9 @@ static_assert(bfloat16(0.0) == LIBC_NAMESPACE::shared::asinbf16(bfloat16(0.0)));
static_assert(bfloat16(0.0) == LIBC_NAMESPACE::shared::ceilbf16(bfloat16(0.0)));
static_assert(bfloat16(1.0) ==
LIBC_NAMESPACE::shared::fabsbf16(bfloat16(-1.0)));
+static_assert(bfloat16(2.0) ==
+ LIBC_NAMESPACE::shared::fmaximum_mag_numbf16(bfloat16(1.0),
+ bfloat16(2.0)));
static_assert(bfloat16(0.0) ==
LIBC_NAMESPACE::shared::copysignbf16(bfloat16(0.0),
bfloat16(0.0)));
>From 1794b379d3c0195fee4dbcfedeba9127ef914638 Mon Sep 17 00:00:00 2001
From: hulxv <hulxxv at gmail.com>
Date: Sat, 25 Apr 2026 22:12:05 +0300
Subject: [PATCH 7/8] comments
---
libc/src/__support/FPUtil/BasicOperations.h | 20 +++++++++-----------
libc/src/__support/math/CMakeLists.txt | 4 ----
libc/test/shared/shared_math_test.cpp | 1 -
3 files changed, 9 insertions(+), 16 deletions(-)
diff --git a/libc/src/__support/FPUtil/BasicOperations.h b/libc/src/__support/FPUtil/BasicOperations.h
index d4e53b65ee3c6..2da9b55673b09 100644
--- a/libc/src/__support/FPUtil/BasicOperations.h
+++ b/libc/src/__support/FPUtil/BasicOperations.h
@@ -34,27 +34,25 @@ namespace internal {
template <typename T>
LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_floating_point_v<T>, T>
-max(T x, T y) {
+constexpr_max(T x, T y) {
FPBits<T> x_bits(x);
FPBits<T> y_bits(y);
-
- // To make sure that fmax(+0, -0) == +0 == fmax(-0, +0), whenever x and y
- // have different signs and both are not NaNs, we return the number with
- // positive sign.
if (x_bits.sign() != y_bits.sign())
return x_bits.is_pos() ? x : y;
return x > y ? x : y;
}
+template <typename T>
+LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_floating_point_v<T>, T>
+max(T x, T y) {
+ return constexpr_max(x, y);
+}
+
#ifdef LIBC_TYPES_HAS_FLOAT16
#if defined(__LIBC_USE_BUILTIN_FMAXF16_FMINF16)
template <> LIBC_INLINE constexpr float16 max(float16 x, float16 y) {
- if (cpp::is_constant_evaluated()) {
- FPBits<float16> x_bits(x), y_bits(y);
- if (x_bits.sign() != y_bits.sign())
- return x_bits.is_pos() ? x : y;
- return x > y ? x : y;
- }
+ if (cpp::is_constant_evaluated())
+ return constexpr_max(x, y);
return __builtin_fmaxf16(x, y);
}
#elif !defined(LIBC_TARGET_ARCH_IS_AARCH64)
diff --git a/libc/src/__support/math/CMakeLists.txt b/libc/src/__support/math/CMakeLists.txt
index d4a8caf240a3e..2fd5a437cd2eb 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -1653,8 +1653,6 @@ add_header_library(
DEPENDS
libc.src.__support.FPUtil.basic_operations
libc.src.__support.macros.config
- FLAGS
- MISC_MATH_BASIC_OPS_OPT
)
add_header_library(
@@ -1676,8 +1674,6 @@ add_header_library(
DEPENDS
libc.src.__support.FPUtil.basic_operations
libc.src.__support.macros.config
- FLAGS
- MISC_MATH_BASIC_OPS_OPT
)
add_header_library(
diff --git a/libc/test/shared/shared_math_test.cpp b/libc/test/shared/shared_math_test.cpp
index ccbc869abf5e6..81ba675c1e71a 100644
--- a/libc/test/shared/shared_math_test.cpp
+++ b/libc/test/shared/shared_math_test.cpp
@@ -482,7 +482,6 @@ TEST(LlvmLibcSharedMathTest, AllBFloat16) {
EXPECT_EQ(0, LIBC_NAMESPACE::shared::canonicalizebf16(&canonicalizebf16_cx,
&canonicalizebf16_x));
EXPECT_FP_EQ(bfloat16(0.0), canonicalizebf16_cx);
-
EXPECT_FP_EQ(bfloat16(0.0), LIBC_NAMESPACE::shared::cbrtbf16(bfloat16(0.0)));
EXPECT_FP_EQ(bfloat16(0.0), LIBC_NAMESPACE::shared::ceilbf16(bfloat16(0.0)));
EXPECT_FP_EQ(bfloat16(0.0), LIBC_NAMESPACE::shared::copysignbf16(
>From b2e1ec1193b5f56da60ddac96c1ae586e3d4c955 Mon Sep 17 00:00:00 2001
From: Muhammad Bassiouni <60100307+bassiounix at users.noreply.github.com>
Date: Sat, 25 Apr 2026 23:31:17 +0300
Subject: [PATCH 8/8] Update libc/test/shared/shared_math_test.cpp
---
libc/test/shared/shared_math_test.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libc/test/shared/shared_math_test.cpp b/libc/test/shared/shared_math_test.cpp
index 81ba675c1e71a..0d918af02ca45 100644
--- a/libc/test/shared/shared_math_test.cpp
+++ b/libc/test/shared/shared_math_test.cpp
@@ -182,7 +182,7 @@ TEST(LlvmLibcSharedMathTest, AllFloat) {
EXPECT_FP_EQ(0.0f, LIBC_NAMESPACE::shared::fdimf(0.0f, 0.0f));
EXPECT_FP_EQ(0.0f, LIBC_NAMESPACE::shared::floorf(0.0f));
EXPECT_FP_EQ(0.0f, LIBC_NAMESPACE::shared::fmaxf(0.0f, 0.0f));
- EXPECT_FP_EQ(0x0p+0f, LIBC_NAMESPACE::shared::fmaximum_mag_numf(0.0f, 0.0f));
+ EXPECT_FP_EQ(0.0f, LIBC_NAMESPACE::shared::fmaximum_mag_numf(0.0f, 0.0f));
float getpayloadf_x = 0.0f;
EXPECT_FP_EQ(-1.0f, LIBC_NAMESPACE::shared::getpayloadf(&getpayloadf_x));
More information about the libc-commits
mailing list