File tree Expand file tree Collapse file tree 1 file changed +1
-20
lines changed Expand file tree Collapse file tree 1 file changed +1
-20
lines changed Original file line number Diff line number Diff line change @@ -226,30 +226,11 @@ LIBC_INLINE constexpr To bit_or_static_cast(const From &from) {
226
226
}
227
227
}
228
228
229
- #define SPECIALIZE_FLZ (NAME, TYPE, BUILTIN ) \
230
- template <> [[nodiscard]] LIBC_INLINE constexpr int NAME<TYPE>(TYPE value) { \
231
- static_assert (cpp::is_unsigned_v<TYPE>); \
232
- return value == cpp::numeric_limits<TYPE>::max () \
233
- ? 0 \
234
- : BUILTIN (static_cast <TYPE>(~value)) + 1 ; \
235
- }
236
-
237
229
template <typename T, typename = cpp::enable_if_t <cpp::is_unsigned_v<T>>>
238
230
[[nodiscard]] LIBC_INLINE constexpr int first_leading_zero (T value) {
239
- return value == cpp::numeric_limits<T>::max ()
240
- ? 0
241
- : countl_zero (static_cast <T>(~value)) + 1 ;
231
+ return value == cpp::numeric_limits<T>::max () ? 0 : countl_one (value) + 1 ;
242
232
}
243
233
244
- #if LIBC_HAS_BUILTIN(__builtin_clzs)
245
- SPECIALIZE_FLZ (first_leading_zero, unsigned short , __builtin_clzs)
246
- #endif
247
- SPECIALIZE_FLZ (first_leading_zero, unsigned int , __builtin_clz)
248
- SPECIALIZE_FLZ (first_leading_zero, unsigned long , __builtin_clzl)
249
- SPECIALIZE_FLZ (first_leading_zero, unsigned long long , __builtin_clzll)
250
-
251
- #undef SPECIALIZE_FLZ
252
-
253
234
} // namespace LIBC_NAMESPACE::cpp
254
235
255
236
#endif // LLVM_LIBC_SRC___SUPPORT_CPP_BIT_H
You can’t perform that action at this time.
0 commit comments