[libc-commits] [libc] [libc][math] Implement `issignaling[f|l]` as a libc math function (PR #110556)
Shourya Goel via libc-commits
libc-commits at lists.llvm.org
Mon Sep 30 12:58:22 PDT 2024
https://github.com/Sh0g0-1758 updated https://github.com/llvm/llvm-project/pull/110556
>From 3665111e2f0aed479f6c43ac4cf55ab9aa21dbbc Mon Sep 17 00:00:00 2001
From: Sh0g0-1758 <shouryagoel10000 at gmail.com>
Date: Tue, 1 Oct 2024 00:52:00 +0530
Subject: [PATCH 1/4] Implemented Issignaling
---
libc/config/linux/aarch64/entrypoints.txt | 3 +
libc/config/linux/riscv/entrypoints.txt | 3 +
libc/config/linux/x86_64/entrypoints.txt | 3 +
libc/src/__support/FPUtil/BasicOperations.h | 10 ++++
libc/src/math/CMakeLists.txt | 4 ++
libc/src/math/generic/CMakeLists.txt | 30 ++++++++++
libc/src/math/generic/issignaling.cpp | 18 ++++++
libc/src/math/generic/issignalingf.cpp | 18 ++++++
libc/src/math/generic/issignalingl.cpp | 18 ++++++
libc/src/math/issignaling.h | 20 +++++++
libc/src/math/issignalingf.h | 20 +++++++
libc/src/math/issignalingl.h | 20 +++++++
libc/test/src/math/smoke/CMakeLists.txt | 39 +++++++++++++
libc/test/src/math/smoke/IsSignalingTest.h | 58 +++++++++++++++++++
libc/test/src/math/smoke/issignaling_test.cpp | 13 +++++
.../test/src/math/smoke/issignalingf_test.cpp | 13 +++++
.../test/src/math/smoke/issignalingl_test.cpp | 13 +++++
17 files changed, 303 insertions(+)
create mode 100644 libc/src/math/generic/issignaling.cpp
create mode 100644 libc/src/math/generic/issignalingf.cpp
create mode 100644 libc/src/math/generic/issignalingl.cpp
create mode 100644 libc/src/math/issignaling.h
create mode 100644 libc/src/math/issignalingf.h
create mode 100644 libc/src/math/issignalingl.h
create mode 100644 libc/test/src/math/smoke/IsSignalingTest.h
create mode 100644 libc/test/src/math/smoke/issignaling_test.cpp
create mode 100644 libc/test/src/math/smoke/issignalingf_test.cpp
create mode 100644 libc/test/src/math/smoke/issignalingl_test.cpp
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index 64fbe1a250c0ba..21288d894705bc 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -479,6 +479,9 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.isnan
libc.src.math.isnanf
libc.src.math.isnanl
+ libc.src.math.issignaling
+ libc.src.math.issignalingf
+ libc.src.math.issignalingl
libc.src.math.ldexp
libc.src.math.ldexpf
libc.src.math.ldexpl
diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt
index ff3d821c664c5b..135a46099cb1fc 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -482,6 +482,9 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.isnan
libc.src.math.isnanf
libc.src.math.isnanl
+ libc.src.math.issignaling
+ libc.src.math.issignalingf
+ libc.src.math.issignalingl
libc.src.math.ldexp
libc.src.math.ldexpf
libc.src.math.ldexpl
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index dd658af3bfb674..d877e3d696c67a 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -482,6 +482,9 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.isnan
libc.src.math.isnanf
libc.src.math.isnanl
+ libc.src.math.issignaling
+ libc.src.math.issignalingf
+ libc.src.math.issignalingl
libc.src.math.ldexp
libc.src.math.ldexpf
libc.src.math.ldexpl
diff --git a/libc/src/__support/FPUtil/BasicOperations.h b/libc/src/__support/FPUtil/BasicOperations.h
index 824c9bfb3947f3..5b14feabe441a7 100644
--- a/libc/src/__support/FPUtil/BasicOperations.h
+++ b/libc/src/__support/FPUtil/BasicOperations.h
@@ -247,6 +247,16 @@ LIBC_INLINE T fdim(T x, T y) {
return (x > y ? x - y : 0);
}
+template <typename T, cpp::enable_if_t<cpp::is_floating_point_v<T>, int> = 0>
+LIBC_INLINE int issignaling(const T &x) {
+ FPBits<T> sx(x);
+ if (LIBC_UNLIKELY(sx.is_signaling_nan())) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
template <typename T, cpp::enable_if_t<cpp::is_floating_point_v<T>, int> = 0>
LIBC_INLINE int canonicalize(T &cx, const T &x) {
FPBits<T> sx(x);
diff --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt
index 3cba34fc249322..440f343f5c0bc0 100644
--- a/libc/src/math/CMakeLists.txt
+++ b/libc/src/math/CMakeLists.txt
@@ -302,6 +302,10 @@ add_math_entrypoint_object(isnan)
add_math_entrypoint_object(isnanf)
add_math_entrypoint_object(isnanl)
+add_math_entrypoint_object(issignaling)
+add_math_entrypoint_object(issignalingf)
+add_math_entrypoint_object(issignalingl)
+
add_math_entrypoint_object(llogb)
add_math_entrypoint_object(llogbf)
add_math_entrypoint_object(llogbl)
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index d0676d03420c68..17e014adcae984 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -3377,6 +3377,36 @@ add_entrypoint_object(
-O3
)
+add_entrypoint_object(
+ issignaling
+ SRCS
+ issignaling.cpp
+ HDRS
+ ../issignaling.h
+ COMPILE_OPTIONS
+ -O3
+)
+
+add_entrypoint_object(
+ issignalingf
+ SRCS
+ issignalingf.cpp
+ HDRS
+ ../issignalingf.h
+ COMPILE_OPTIONS
+ -O3
+)
+
+add_entrypoint_object(
+ issignalingl
+ SRCS
+ issignalingl.cpp
+ HDRS
+ ../issignalingl.h
+ COMPILE_OPTIONS
+ -O3
+)
+
add_entrypoint_object(
isnan
SRCS
diff --git a/libc/src/math/generic/issignaling.cpp b/libc/src/math/generic/issignaling.cpp
new file mode 100644
index 00000000000000..26220b4dec2004
--- /dev/null
+++ b/libc/src/math/generic/issignaling.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of issignaling function ----------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/issignaling.h"
+#include "src/__support/FPUtil/BasicOperations.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(int, issignaling, (double x)) { return fputil::issignaling(x); }
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/issignalingf.cpp b/libc/src/math/generic/issignalingf.cpp
new file mode 100644
index 00000000000000..d2e3e2633225ab
--- /dev/null
+++ b/libc/src/math/generic/issignalingf.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of issignalingf function ---------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/issignalingf.h"
+#include "src/__support/FPUtil/BasicOperations.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(int, issignalingf, (float x)) { return fputil::issignaling(x); }
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/issignalingl.cpp b/libc/src/math/generic/issignalingl.cpp
new file mode 100644
index 00000000000000..8b111d91e7ccf1
--- /dev/null
+++ b/libc/src/math/generic/issignalingl.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of issignalingl function ----------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/issignalingl.h"
+#include "src/__support/FPUtil/BasicOperations.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(int, issignalingl, (long double x)) { return fputil::issignaling(x); }
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/issignaling.h b/libc/src/math/issignaling.h
new file mode 100644
index 00000000000000..093fd7d48770dd
--- /dev/null
+++ b/libc/src/math/issignaling.h
@@ -0,0 +1,20 @@
+//===-- Implementation header for issignaling -------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_MATH_ISSIGNALING_H
+#define LLVM_LIBC_SRC_MATH_ISSIGNALING_H
+
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+int issignaling(double x);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_ISSIGNALING_H
diff --git a/libc/src/math/issignalingf.h b/libc/src/math/issignalingf.h
new file mode 100644
index 00000000000000..97522600916cce
--- /dev/null
+++ b/libc/src/math/issignalingf.h
@@ -0,0 +1,20 @@
+//===-- Implementation header for issignalingf ------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_MATH_ISSIGNALINGF_H
+#define LLVM_LIBC_SRC_MATH_ISSIGNALINGF_H
+
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+int issignalingf(float x);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_ISSIGNALINGF_H
diff --git a/libc/src/math/issignalingl.h b/libc/src/math/issignalingl.h
new file mode 100644
index 00000000000000..edc039416d1f4e
--- /dev/null
+++ b/libc/src/math/issignalingl.h
@@ -0,0 +1,20 @@
+//===-- Implementation header for issignalingl ------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_MATH_ISSIGNALINGL_H
+#define LLVM_LIBC_SRC_MATH_ISSIGNALINGL_H
+
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+int issignalingl(long double x);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_ISSIGNALINGL_H
diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index 9f9203c491d044..bb89f75a8fdad0 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -1597,6 +1597,45 @@ add_fp_unittest(
libc.src.__support.FPUtil.manipulation_functions
)
+add_fp_unittest(
+ issignaling_test
+ SUITE
+ libc-math-smoke-tests
+ SRCS
+ issignaling_test.cpp
+ HDRS
+ IsSignalingTest.h
+ DEPENDS
+ libc.src.math.issignaling
+ libc.src.__support.FPUtil.fp_bits
+)
+
+add_fp_unittest(
+ issignalingf_test
+ SUITE
+ libc-math-smoke-tests
+ SRCS
+ issignalingf_test.cpp
+ HDRS
+ IsSignalingTest.h
+ DEPENDS
+ libc.src.math.issignalingf
+ libc.src.__support.FPUtil.fp_bits
+)
+
+add_fp_unittest(
+ issignalingl_test
+ SUITE
+ libc-math-smoke-tests
+ SRCS
+ issignalingl_test.cpp
+ HDRS
+ IsSignalingTest.h
+ DEPENDS
+ libc.src.math.issignalingl
+ libc.src.__support.FPUtil.fp_bits
+)
+
add_fp_unittest(
llogb_test
SUITE
diff --git a/libc/test/src/math/smoke/IsSignalingTest.h b/libc/test/src/math/smoke/IsSignalingTest.h
new file mode 100644
index 00000000000000..6beabfcd775144
--- /dev/null
+++ b/libc/test/src/math/smoke/IsSignalingTest.h
@@ -0,0 +1,58 @@
+//===-- Utility class to test issignaling[f|l] ------------------*- 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_TEST_SRC_MATH_SMOKE_ISSIGNALINGTEST_H
+#define LLVM_LIBC_TEST_SRC_MATH_SMOKE_ISSIGNALINGTEST_H
+
+#include "test/UnitTest/FEnvSafeTest.h"
+#include "test/UnitTest/FPMatcher.h"
+#include "test/UnitTest/Test.h"
+
+#include "hdr/math_macros.h"
+
+template <typename T>
+class IssignalingTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
+
+ DECLARE_SPECIAL_CONSTANTS(T)
+
+public:
+ typedef int (*IsSignalingFunc)(T);
+
+ void testSpecialNumbers(IsSignalingFunc func) {
+ EXPECT_EQ(func(aNaN), 0);
+ EXPECT_EQ(func(neg_aNaN), 0);
+ EXPECT_EQ(func(sNaN), 1);
+ EXPECT_EQ(func(neg_sNaN), 1);
+ EXPECT_EQ(func(inf), 0);
+ EXPECT_EQ(func(neg_inf), 0);
+ EXPECT_EQ(func(min_normal), 0);
+ EXPECT_EQ(func(max_normal), 0);
+ EXPECT_EQ(func(neg_max_normal), 0);
+ EXPECT_EQ(func(min_denormal), 0);
+ EXPECT_EQ(func(neg_min_denormal), 0);
+ EXPECT_EQ(func(max_denormal), 0);
+ EXPECT_EQ(func(zero), 0);
+ EXPECT_EQ(func(neg_zero), 0);
+ }
+
+ void testRoundedNumbers(IsSignalingFunc func) {
+ EXPECT_EQ(func(T(1.0)), 0);
+ EXPECT_EQ(func(T(-1.0)), 0);
+ EXPECT_EQ(func(T(10.0)), 0);
+ EXPECT_EQ(func(T(-10.0)), 0);
+ EXPECT_EQ(func(T(1234.0)), 0);
+ EXPECT_EQ(func(T(-1234.0)), 0);
+ }
+};
+
+#define LIST_ISSIGNALING_TESTS(T, func) \
+ using LlvmLibcIsSignalingTest = IssignalingTest<T>; \
+ TEST_F(LlvmLibcIsSignalingTest, SpecialNumbers) { testSpecialNumbers(&func); }\
+ TEST_F(LlvmLibcIsSignalingTest, RoundedNubmers) { testRoundedNumbers(&func); }
+
+#endif // LLVM_LIBC_TEST_SRC_MATH_SMOKE_ISSIGNALINGTEST_H
diff --git a/libc/test/src/math/smoke/issignaling_test.cpp b/libc/test/src/math/smoke/issignaling_test.cpp
new file mode 100644
index 00000000000000..4292cbbb852b49
--- /dev/null
+++ b/libc/test/src/math/smoke/issignaling_test.cpp
@@ -0,0 +1,13 @@
+//===-- Unittests for issignaling -----------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "IsSignalingTest.h"
+
+#include "src/math/issignaling.h"
+
+LIST_ISSIGNALING_TESTS(double, LIBC_NAMESPACE::issignaling)
diff --git a/libc/test/src/math/smoke/issignalingf_test.cpp b/libc/test/src/math/smoke/issignalingf_test.cpp
new file mode 100644
index 00000000000000..0ceb9a80c03108
--- /dev/null
+++ b/libc/test/src/math/smoke/issignalingf_test.cpp
@@ -0,0 +1,13 @@
+//===-- Unittests for issignalingf ----------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "IsSignalingTest.h"
+
+#include "src/math/issignalingf.h"
+
+LIST_ISSIGNALING_TESTS(float, LIBC_NAMESPACE::issignalingf)
diff --git a/libc/test/src/math/smoke/issignalingl_test.cpp b/libc/test/src/math/smoke/issignalingl_test.cpp
new file mode 100644
index 00000000000000..049769009ba7c6
--- /dev/null
+++ b/libc/test/src/math/smoke/issignalingl_test.cpp
@@ -0,0 +1,13 @@
+//===-- Unittests for issignalingl ----------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "IsSignalingTest.h"
+
+#include "src/math/issignalingl.h"
+
+LIST_ISSIGNALING_TESTS(long double, LIBC_NAMESPACE::issignalingl)
>From 54458ba8fadd5b189d6921e609c246d286d429ab Mon Sep 17 00:00:00 2001
From: Sh0g0-1758 <shouryagoel10000 at gmail.com>
Date: Tue, 1 Oct 2024 00:52:49 +0530
Subject: [PATCH 2/4] ran fmt
---
libc/src/math/generic/issignaling.cpp | 4 +++-
libc/src/math/generic/issignalingf.cpp | 4 +++-
libc/src/math/generic/issignalingl.cpp | 7 +++++--
libc/test/src/math/smoke/IsSignalingTest.h | 4 +++-
4 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/libc/src/math/generic/issignaling.cpp b/libc/src/math/generic/issignaling.cpp
index 26220b4dec2004..0687a32817b295 100644
--- a/libc/src/math/generic/issignaling.cpp
+++ b/libc/src/math/generic/issignaling.cpp
@@ -13,6 +13,8 @@
namespace LIBC_NAMESPACE_DECL {
-LLVM_LIBC_FUNCTION(int, issignaling, (double x)) { return fputil::issignaling(x); }
+LLVM_LIBC_FUNCTION(int, issignaling, (double x)) {
+ return fputil::issignaling(x);
+}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/issignalingf.cpp b/libc/src/math/generic/issignalingf.cpp
index d2e3e2633225ab..410bf7b4d42782 100644
--- a/libc/src/math/generic/issignalingf.cpp
+++ b/libc/src/math/generic/issignalingf.cpp
@@ -13,6 +13,8 @@
namespace LIBC_NAMESPACE_DECL {
-LLVM_LIBC_FUNCTION(int, issignalingf, (float x)) { return fputil::issignaling(x); }
+LLVM_LIBC_FUNCTION(int, issignalingf, (float x)) {
+ return fputil::issignaling(x);
+}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/issignalingl.cpp b/libc/src/math/generic/issignalingl.cpp
index 8b111d91e7ccf1..b399bd2d5bc6a7 100644
--- a/libc/src/math/generic/issignalingl.cpp
+++ b/libc/src/math/generic/issignalingl.cpp
@@ -1,4 +1,5 @@
-//===-- Implementation of issignalingl function ----------------------------===//
+//===-- Implementation of issignalingl function
+//----------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -13,6 +14,8 @@
namespace LIBC_NAMESPACE_DECL {
-LLVM_LIBC_FUNCTION(int, issignalingl, (long double x)) { return fputil::issignaling(x); }
+LLVM_LIBC_FUNCTION(int, issignalingl, (long double x)) {
+ return fputil::issignaling(x);
+}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/test/src/math/smoke/IsSignalingTest.h b/libc/test/src/math/smoke/IsSignalingTest.h
index 6beabfcd775144..60773e2ccc4161 100644
--- a/libc/test/src/math/smoke/IsSignalingTest.h
+++ b/libc/test/src/math/smoke/IsSignalingTest.h
@@ -52,7 +52,9 @@ class IssignalingTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
#define LIST_ISSIGNALING_TESTS(T, func) \
using LlvmLibcIsSignalingTest = IssignalingTest<T>; \
- TEST_F(LlvmLibcIsSignalingTest, SpecialNumbers) { testSpecialNumbers(&func); }\
+ TEST_F(LlvmLibcIsSignalingTest, SpecialNumbers) { \
+ testSpecialNumbers(&func); \
+ } \
TEST_F(LlvmLibcIsSignalingTest, RoundedNubmers) { testRoundedNumbers(&func); }
#endif // LLVM_LIBC_TEST_SRC_MATH_SMOKE_ISSIGNALINGTEST_H
>From 275756cd5f00727116a75418178d32f394737d1d Mon Sep 17 00:00:00 2001
From: Shourya Goel <shouryagoel10000 at gmail.com>
Date: Tue, 1 Oct 2024 01:16:25 +0530
Subject: [PATCH 3/4] Update issignalingl.cpp
---
libc/src/math/generic/issignalingl.cpp | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/libc/src/math/generic/issignalingl.cpp b/libc/src/math/generic/issignalingl.cpp
index b399bd2d5bc6a7..a3959bcae23575 100644
--- a/libc/src/math/generic/issignalingl.cpp
+++ b/libc/src/math/generic/issignalingl.cpp
@@ -1,5 +1,4 @@
-//===-- Implementation of issignalingl function
-//----------------------------===//
+//===-- Implementation of issignalingl function ---------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
>From 10976a1c5bb05bdabcf8d9c0d75c0f9d9f405e71 Mon Sep 17 00:00:00 2001
From: Shourya Goel <shouryagoel10000 at gmail.com>
Date: Tue, 1 Oct 2024 01:28:13 +0530
Subject: [PATCH 4/4] Update BasicOperations.h
---
libc/src/__support/FPUtil/BasicOperations.h | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/libc/src/__support/FPUtil/BasicOperations.h b/libc/src/__support/FPUtil/BasicOperations.h
index 5b14feabe441a7..4e6ca52c18b479 100644
--- a/libc/src/__support/FPUtil/BasicOperations.h
+++ b/libc/src/__support/FPUtil/BasicOperations.h
@@ -250,11 +250,8 @@ LIBC_INLINE T fdim(T x, T y) {
template <typename T, cpp::enable_if_t<cpp::is_floating_point_v<T>, int> = 0>
LIBC_INLINE int issignaling(const T &x) {
FPBits<T> sx(x);
- if (LIBC_UNLIKELY(sx.is_signaling_nan())) {
- return 1;
- } else {
- return 0;
- }
+ if (LIBC_UNLIKELY(sx.is_signaling_nan())) return 1;
+ return 0;
}
template <typename T, cpp::enable_if_t<cpp::is_floating_point_v<T>, int> = 0>
More information about the libc-commits
mailing list