[libc-commits] [libc] [llvm] [libc][math] Refactor copysign family to header-only (PR #182137)
via libc-commits
libc-commits at lists.llvm.org
Wed Feb 18 12:54:56 PST 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libc
Author: Mohamed Emad (hulxv)
<details>
<summary>Changes</summary>
Refactors the copysign math family to be header-only.
Closes https://github.com/llvm/llvm-project/issues/182136
Target Functions:
- copysign
- copysignbf16
- copysignf
- copysignf128
- copysignf16
- copysignl
---
Patch is 26.83 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/182137.diff
24 Files Affected:
- (modified) libc/shared/math.h (+6)
- (added) libc/shared/math/copysign.h (+22)
- (added) libc/shared/math/copysignbf16.h (+22)
- (added) libc/shared/math/copysignf.h (+22)
- (added) libc/shared/math/copysignf128.h (+28)
- (added) libc/shared/math/copysignf16.h (+28)
- (added) libc/shared/math/copysignl.h (+22)
- (modified) libc/src/__support/math/CMakeLists.txt (+51)
- (added) libc/src/__support/math/copysign.h (+30)
- (added) libc/src/__support/math/copysignbf16.h (+27)
- (added) libc/src/__support/math/copysignf.h (+30)
- (added) libc/src/__support/math/copysignf128.h (+32)
- (added) libc/src/__support/math/copysignf16.h (+36)
- (added) libc/src/__support/math/copysignl.h (+26)
- (modified) libc/src/math/generic/CMakeLists.txt (+6-20)
- (modified) libc/src/math/generic/copysign.cpp (+2-8)
- (modified) libc/src/math/generic/copysignbf16.cpp (+2-5)
- (modified) libc/src/math/generic/copysignf.cpp (+2-8)
- (modified) libc/src/math/generic/copysignf128.cpp (+2-4)
- (modified) libc/src/math/generic/copysignf16.cpp (+2-8)
- (modified) libc/src/math/generic/copysignl.cpp (+2-4)
- (modified) libc/test/shared/CMakeLists.txt (+6)
- (modified) libc/test/shared/shared_math_test.cpp (+14)
- (modified) utils/bazel/llvm-project-overlay/libc/BUILD.bazel (+87-5)
``````````diff
diff --git a/libc/shared/math.h b/libc/shared/math.h
index 8a5aca82c6ec3..0b9d15a144649 100644
--- a/libc/shared/math.h
+++ b/libc/shared/math.h
@@ -45,6 +45,12 @@
#include "math/canonicalizel.h"
#include "math/cbrt.h"
#include "math/cbrtf.h"
+#include "math/copysign.h"
+#include "math/copysignbf16.h"
+#include "math/copysignf.h"
+#include "math/copysignf128.h"
+#include "math/copysignf16.h"
+#include "math/copysignl.h"
#include "math/cos.h"
#include "math/cosf.h"
#include "math/cosf16.h"
diff --git a/libc/shared/math/copysign.h b/libc/shared/math/copysign.h
new file mode 100644
index 0000000000000..b64ba513f9dce
--- /dev/null
+++ b/libc/shared/math/copysign.h
@@ -0,0 +1,22 @@
+//===-- Shared copysign 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_COPYSIGN_H
+#define LLVM_LIBC_SHARED_MATH_COPYSIGN_H
+
+#include "src/__support/math/copysign.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::copysign;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_COPYSIGN_H
diff --git a/libc/shared/math/copysignbf16.h b/libc/shared/math/copysignbf16.h
new file mode 100644
index 0000000000000..3bb24da81f19e
--- /dev/null
+++ b/libc/shared/math/copysignbf16.h
@@ -0,0 +1,22 @@
+//===-- Shared copysignbf16 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_COPYSIGNBF16_H
+#define LLVM_LIBC_SHARED_MATH_COPYSIGNBF16_H
+
+#include "src/__support/math/copysignbf16.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::copysignbf16;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_COPYSIGNBF16_H
diff --git a/libc/shared/math/copysignf.h b/libc/shared/math/copysignf.h
new file mode 100644
index 0000000000000..5551f51ed705f
--- /dev/null
+++ b/libc/shared/math/copysignf.h
@@ -0,0 +1,22 @@
+//===-- Shared copysignf 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_COPYSIGNF_H
+#define LLVM_LIBC_SHARED_MATH_COPYSIGNF_H
+
+#include "src/__support/math/copysignf.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::copysignf;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_COPYSIGNF_H
diff --git a/libc/shared/math/copysignf128.h b/libc/shared/math/copysignf128.h
new file mode 100644
index 0000000000000..59e2f68319120
--- /dev/null
+++ b/libc/shared/math/copysignf128.h
@@ -0,0 +1,28 @@
+//===-- Shared copysignf128 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_COPYSIGNF128_H
+#define LLVM_LIBC_SHARED_MATH_COPYSIGNF128_H
+
+#include "include/llvm-libc-types/float128.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT128
+
+#include "src/__support/math/copysignf128.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::copysignf128;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT128
+
+#endif // LLVM_LIBC_SHARED_MATH_COPYSIGNF128_H
diff --git a/libc/shared/math/copysignf16.h b/libc/shared/math/copysignf16.h
new file mode 100644
index 0000000000000..bd66d8da6488a
--- /dev/null
+++ b/libc/shared/math/copysignf16.h
@@ -0,0 +1,28 @@
+//===-- Shared copysignf16 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_COPYSIGNF16_H
+#define LLVM_LIBC_SHARED_MATH_COPYSIGNF16_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "src/__support/math/copysignf16.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::copysignf16;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT16
+
+#endif // LLVM_LIBC_SHARED_MATH_COPYSIGNF16_H
diff --git a/libc/shared/math/copysignl.h b/libc/shared/math/copysignl.h
new file mode 100644
index 0000000000000..5bb0907eaf173
--- /dev/null
+++ b/libc/shared/math/copysignl.h
@@ -0,0 +1,22 @@
+//===-- Shared copysignl 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_COPYSIGNL_H
+#define LLVM_LIBC_SHARED_MATH_COPYSIGNL_H
+
+#include "src/__support/math/copysignl.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::copysignl;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_COPYSIGNL_H
diff --git a/libc/src/__support/math/CMakeLists.txt b/libc/src/__support/math/CMakeLists.txt
index e21fe8ef0ab93..1970a48271302 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -484,6 +484,57 @@ add_header_library(
libc.src.__support.macros.config
libc.src.__support.number_pair
)
+add_header_library(
+ copysign
+ HDRS
+ copysign.h
+ DEPENDS
+ libc.src.__support.FPUtil.manipulation_functions
+ libc.src.__support.macros.config
+)
+add_header_library(
+ copysignbf16
+ HDRS
+ copysignbf16.h
+ DEPENDS
+ libc.src.__support.FPUtil.bfloat16
+ libc.src.__support.FPUtil.manipulation_functions
+ libc.src.__support.macros.config
+)
+add_header_library(
+ copysignf
+ HDRS
+ copysignf.h
+ DEPENDS
+ libc.src.__support.FPUtil.manipulation_functions
+ libc.src.__support.macros.config
+)
+add_header_library(
+ copysignf128
+ HDRS
+ copysignf128.h
+ DEPENDS
+ libc.include.llvm-libc-types.float128
+ libc.src.__support.FPUtil.manipulation_functions
+ libc.src.__support.macros.config
+)
+add_header_library(
+ copysignf16
+ HDRS
+ copysignf16.h
+ DEPENDS
+ libc.include.llvm-libc-macros.float16_macros
+ libc.src.__support.FPUtil.manipulation_functions
+ libc.src.__support.macros.config
+)
+add_header_library(
+ copysignl
+ HDRS
+ copysignl.h
+ DEPENDS
+ libc.src.__support.FPUtil.manipulation_functions
+ libc.src.__support.macros.config
+)
add_header_library(
cos
diff --git a/libc/src/__support/math/copysign.h b/libc/src/__support/math/copysign.h
new file mode 100644
index 0000000000000..7ba974b3664cd
--- /dev/null
+++ b/libc/src/__support/math/copysign.h
@@ -0,0 +1,30 @@
+//===-- Implementation header for copysign ----------------------*- 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_COPYSIGN_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_COPYSIGN_H
+
+#include "src/__support/FPUtil/ManipulationFunctions.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+LIBC_INLINE double copysign(double x, double y) {
+#ifdef __LIBC_MISC_MATH_BASIC_OPS_OPT
+ return __builtin_copysign(x, y);
+#else
+ return fputil::copysign(x, y);
+#endif
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_COPYSIGN_H
diff --git a/libc/src/__support/math/copysignbf16.h b/libc/src/__support/math/copysignbf16.h
new file mode 100644
index 0000000000000..60b72848101f1
--- /dev/null
+++ b/libc/src/__support/math/copysignbf16.h
@@ -0,0 +1,27 @@
+//===-- Implementation header for copysignbf16 ------------------*- 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_COPYSIGNBF16_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_COPYSIGNBF16_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 copysignbf16(bfloat16 x, bfloat16 y) {
+ return fputil::copysign(x, y);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_COPYSIGNBF16_H
diff --git a/libc/src/__support/math/copysignf.h b/libc/src/__support/math/copysignf.h
new file mode 100644
index 0000000000000..a8b8adb5631b1
--- /dev/null
+++ b/libc/src/__support/math/copysignf.h
@@ -0,0 +1,30 @@
+//===-- Implementation header for copysignf ---------------------*- 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_COPYSIGNF_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_COPYSIGNF_H
+
+#include "src/__support/FPUtil/ManipulationFunctions.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+LIBC_INLINE float copysignf(float x, float y) {
+#ifdef __LIBC_MISC_MATH_BASIC_OPS_OPT
+ return __builtin_copysignf(x, y);
+#else
+ return fputil::copysign(x, y);
+#endif
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_COPYSIGNF_H
diff --git a/libc/src/__support/math/copysignf128.h b/libc/src/__support/math/copysignf128.h
new file mode 100644
index 0000000000000..a95f4620572ce
--- /dev/null
+++ b/libc/src/__support/math/copysignf128.h
@@ -0,0 +1,32 @@
+//===-- Implementation header for copysignf128 ------------------*- 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_COPYSIGNF128_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_COPYSIGNF128_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 copysignf128(float128 x, float128 y) {
+ return fputil::copysign(x, y);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT128
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_COPYSIGNF128_H
diff --git a/libc/src/__support/math/copysignf16.h b/libc/src/__support/math/copysignf16.h
new file mode 100644
index 0000000000000..4e79c29256cba
--- /dev/null
+++ b/libc/src/__support/math/copysignf16.h
@@ -0,0 +1,36 @@
+//===-- Implementation header for copysignf16 -------------------*- 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_COPYSIGNF16_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_COPYSIGNF16_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 float16 copysignf16(float16 x, float16 y) {
+#ifdef __LIBC_MISC_MATH_BASIC_OPS_OPT
+ return __builtin_copysignf16(x, y);
+#else
+ return fputil::copysign(x, y);
+#endif
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT16
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_COPYSIGNF16_H
diff --git a/libc/src/__support/math/copysignl.h b/libc/src/__support/math/copysignl.h
new file mode 100644
index 0000000000000..3a420365d8178
--- /dev/null
+++ b/libc/src/__support/math/copysignl.h
@@ -0,0 +1,26 @@
+//===-- Implementation header for copysignl ---------------------*- 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_COPYSIGNL_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_COPYSIGNL_H
+
+#include "src/__support/FPUtil/ManipulationFunctions.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+LIBC_INLINE constexpr long double copysignl(long double x, long double y) {
+ return fputil::copysign(x, y);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_COPYSIGNL_H
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index 57a29665318a3..6d892dbf11c61 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -1517,9 +1517,7 @@ add_entrypoint_object(
HDRS
../copysign.h
DEPENDS
- libc.src.__support.FPUtil.manipulation_functions
- FLAGS
- MISC_MATH_BASIC_OPS_OPT
+ libc.src.__support.math.copysign
)
add_entrypoint_object(
@@ -1529,9 +1527,7 @@ add_entrypoint_object(
HDRS
../copysignf.h
DEPENDS
- libc.src.__support.FPUtil.manipulation_functions
- FLAGS
- MISC_MATH_BASIC_OPS_OPT
+ libc.src.__support.math.copysignf
)
add_entrypoint_object(
@@ -1541,7 +1537,7 @@ add_entrypoint_object(
HDRS
../copysignl.h
DEPENDS
- libc.src.__support.FPUtil.manipulation_functions
+ libc.src.__support.math.copysignl
)
add_entrypoint_object(
@@ -1551,10 +1547,7 @@ add_entrypoint_object(
HDRS
../copysignf16.h
DEPENDS
- libc.src.__support.macros.properties.types
- libc.src.__support.FPUtil.manipulation_functions
- FLAGS
- MISC_MATH_BASIC_OPS_OPT
+ libc.src.__support.math.copysignf16
)
add_entrypoint_object(
@@ -1564,8 +1557,7 @@ add_entrypoint_object(
HDRS
../copysignf128.h
DEPENDS
- libc.src.__support.macros.properties.types
- libc.src.__support.FPUtil.manipulation_functions
+ libc.src.__support.math.copysignf128
)
add_entrypoint_object(
@@ -1575,13 +1567,7 @@ add_entrypoint_object(
HDRS
../copysignbf16.h
DEPENDS
- libc.src.__support.common
- libc.src.__support.macros.config
- libc.src.__support.macros.properties.types
- libc.src.__support.FPUtil.bfloat16
- libc.src.__support.FPUtil.manipulation_functions
- FLAGS
- MISC_MATH_BASIC_OPS_OPT
+ libc.src.__support.math.copysignbf16
)
add_entrypoint_object(
diff --git a/libc/src/math/generic/copysign.cpp b/libc/src/math/generic/copysign.cpp
index 186bb2c5983f4..6d92b0600eeb2 100644
--- a/libc/src/math/generic/copysign.cpp
+++ b/libc/src/math/generic/copysign.cpp
@@ -7,18 +7,12 @@
//===----------------------------------------------------------------------===//
#include "src/math/copysign.h"
-#include "src/__support/FPUtil/ManipulationFunctions.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/copysign.h"
namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(double, copysign, (double x, double y)) {
-#ifdef __LIBC_MISC_MATH_BASIC_OPS_OPT
- return __builtin_copysign(x, y);
-#else
- return fputil::copysign(x, y);
-#endif
+ return math::copysign(x, y);
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/copysignbf16.cpp b/libc/src/math/generic/copysignbf16.cpp
index 48ade2b26981c..548fa42835e5f 100644
--- a/libc/src/math/generic/copysignbf16.cpp
+++ b/libc/src/math/generic/copysignbf16.cpp
@@ -7,15 +7,12 @@
//===----------------------------------------------------------------------===//
#include "src/math/copysignbf16.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/copysignbf16.h"
namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(bfloat16, copysignbf16, (bfloat16 x, bfloat16 y)) {
- return fputil::copysign(x, y);
+ return math::copysignbf16(x, y);
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/copysignf.cpp b/libc/src/math/generic/copysignf.cpp
index c79e50b61ebda..94eeba9eaf705 100644
--- a/libc/src/math/generic/copysignf.cpp
+++ b/libc/src/math/generic/copysignf.cpp
@@ -7,18 +7,12 @@
//===----------------------------------------------------------------------===//
#include "src/math/copysignf.h"
-#include "src/__support/FPUtil/ManipulationFunctions.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/copysignf.h"
namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(float, copysignf, (float x, float y)) {
-#ifdef __LIBC_MISC_MATH_BASIC_OPS_OPT
- return __builtin_copysignf(x, y);
-#else
- return fputil::copysign(x, y);
-#endif
+ return math::copysignf(x, y);
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/copysignf128.cpp b/libc/src/math/generic/copysignf128.cpp
index 9a51c8d5eb8df..9af98f0d10723 100644
--- a/libc/src/math/generic/copysignf128.cpp
+++ b/libc/src/math/generic/copysignf128.cpp
@@ -7,14 +7,12 @@
//===----------------------------------------------------------------------===//
#include "src/math/copysignf128.h"
-#include "src/__support/FPUtil/ManipulationFunctions.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/copysignf128.h"
namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(float128, copysignf128, (float128 x, float128 y)) {
- return fputil::copysign(x, y);
+ return math::copysignf128(x, y);
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/copysignf16.cpp b/libc/src/math/generic/copysignf16.cpp
index 546622f049ebe..23db8faf3211a 100644
--- a/libc/src/math/generic/copysignf16.cpp
+++ b/libc/src/math/generic/copysignf16.cpp
@@ -7,18 +7,12 @@
//===----------------------------------------------------------------------===//
#include "src/math/copysignf16.h"
-#include "src/__support/FPUtil/ManipulationFunctions.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/copysignf16.h"
namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(float16, copysignf16, (float16 x, float16 y)) {
-#ifdef __LIBC_MISC_MATH_BASIC_OPS_OPT
- return __builtin_copysignf16(x, y);
-#else
- return f...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/182137
More information about the libc-commits
mailing list