[libcxx-commits] [libcxx] [libc++] Remove one of the std::signbit overloads (PR #130505)
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Mar 9 12:12:29 PDT 2025
https://github.com/philnik777 created https://github.com/llvm/llvm-project/pull/130505
We'e specialized `std::signbit` for signed and unsigned integral types seperately, even though the optimizer can trivially figure out that `unsigned_value < 0` always false is. This patch removes the specialization, since there is really not much of a benefit to it.
>From dd883fb60a9cc1b2d86a9a86447d1cb1696ebfda Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <nikolasklauser at berlin.de>
Date: Sun, 9 Mar 2025 20:10:37 +0100
Subject: [PATCH] [libc++] Remove one of the std::signbit overloads
---
libcxx/include/__math/traits.h | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/libcxx/include/__math/traits.h b/libcxx/include/__math/traits.h
index 0c96f766a767e..550eb393e2d4f 100644
--- a/libcxx/include/__math/traits.h
+++ b/libcxx/include/__math/traits.h
@@ -13,7 +13,6 @@
#include <__type_traits/enable_if.h>
#include <__type_traits/is_arithmetic.h>
#include <__type_traits/is_integral.h>
-#include <__type_traits/is_signed.h>
#include <__type_traits/promote.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -51,16 +50,11 @@ template <class = void>
return __builtin_signbit(__x);
}
-template <class _A1, __enable_if_t<is_integral<_A1>::value && is_signed<_A1>::value, int> = 0>
+template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>
[[__nodiscard__]] inline _LIBCPP_SIGNBIT_CONSTEXPR _LIBCPP_HIDE_FROM_ABI bool signbit(_A1 __x) _NOEXCEPT {
return __x < 0;
}
-template <class _A1, __enable_if_t<is_integral<_A1>::value && !is_signed<_A1>::value, int> = 0>
-[[__nodiscard__]] inline _LIBCPP_SIGNBIT_CONSTEXPR _LIBCPP_HIDE_FROM_ABI bool signbit(_A1) _NOEXCEPT {
- return false;
-}
-
// isfinite
template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>
More information about the libcxx-commits
mailing list