[libc] [llvm] [libc] Remove UB specializations of type traits for `BigInt` (PR #84035)

via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 6 08:20:33 PST 2024


================
@@ -51,8 +52,10 @@ LIBC_INLINE constexpr To bit_cast(const From &from) {
 #endif // LIBC_HAS_BUILTIN(__builtin_bit_cast)
 }
 
-template <typename T, typename = cpp::enable_if_t<cpp::is_unsigned_v<T>>>
-[[nodiscard]] LIBC_INLINE constexpr bool has_single_bit(T value) {
+template <typename T>
+[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>,
+                                                     bool>
+has_single_bit(T value) {
----------------
lntue wrote:

Just a side question: Is there a simple way to make these template functions be like:
```
has_single_bit(T value)   when sizeof(T) <= 8
has_single_bit(const T &value) when sizeof(T) > 8
```
Especially if this pattern can be applied to many functions easily somehow. 
Last time I experimented with `DoubleDouble` and `DyadicFloat<128>` and it did provide measurable performance improvements.

https://github.com/llvm/llvm-project/pull/84035


More information about the llvm-commits mailing list