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) {
226226 }
227227}
228228
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-
237229template <typename T, typename = cpp::enable_if_t <cpp::is_unsigned_v<T>>>
238230[[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 ;
242232}
243233
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-
253234} // namespace LIBC_NAMESPACE::cpp
254235
255236#endif // LLVM_LIBC_SRC___SUPPORT_CPP_BIT_H
You can’t perform that action at this time.
0 commit comments