File tree Expand file tree Collapse file tree 3 files changed +12
-0
lines changed Expand file tree Collapse file tree 3 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -74,6 +74,9 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int __countl_zero(_Tp __t) _
74
74
if (__t == 0 )
75
75
return numeric_limits<_Tp>::digits;
76
76
77
+ #if __has_builtin(__builtin_clzg)
78
+ return __builtin_clzg (__t ) - (numeric_limits<unsigned >::digits - numeric_limits<_Tp>::digits);
79
+ #else
77
80
if (sizeof (_Tp) <= sizeof (unsigned int ))
78
81
return std::__libcpp_clz (static_cast <unsigned int >(__t )) -
79
82
(numeric_limits<unsigned int >::digits - numeric_limits<_Tp>::digits);
@@ -95,6 +98,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int __countl_zero(_Tp __t) _
95
98
}
96
99
return __ret + __iter;
97
100
}
101
+ #endif // __has_builtin(__builtin_clzg)
98
102
}
99
103
100
104
#if _LIBCPP_STD_VER >= 20
Original file line number Diff line number Diff line change @@ -52,6 +52,9 @@ _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int __coun
52
52
if (__t == 0 )
53
53
return numeric_limits<_Tp>::digits;
54
54
55
+ #if __has_builtin(__builtin_ctz)
56
+ return __builtin_ctz (__t );
57
+ #else
55
58
if (sizeof (_Tp) <= sizeof (unsigned int ))
56
59
return std::__libcpp_ctz (static_cast <unsigned int >(__t ));
57
60
else if (sizeof (_Tp) <= sizeof (unsigned long ))
@@ -67,6 +70,7 @@ _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int __coun
67
70
}
68
71
return __ret + std::__libcpp_ctz (static_cast <unsigned long long >(__t ));
69
72
}
73
+ #endif // __has_builtin(__builtin_ctz)
70
74
}
71
75
72
76
#if _LIBCPP_STD_VER >= 20
Original file line number Diff line number Diff line change @@ -51,6 +51,9 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_popcount(unsigned lo
51
51
52
52
template <__libcpp_unsigned_integer _Tp>
53
53
_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr int popcount (_Tp __t ) noexcept {
54
+ # if __has_builtin(__builtin_popcount)
55
+ return __builtin_popcount (__t );
56
+ # else
54
57
if (sizeof (_Tp) <= sizeof (unsigned int ))
55
58
return std::__libcpp_popcount (static_cast <unsigned int >(__t ));
56
59
else if (sizeof (_Tp) <= sizeof (unsigned long ))
@@ -65,6 +68,7 @@ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr int popcount(_Tp __t) noex
65
68
}
66
69
return __ret;
67
70
}
71
+ # endif // __has_builtin(__builtin_popcount)
68
72
}
69
73
70
74
#endif // _LIBCPP_STD_VER >= 20
You can’t perform that action at this time.
0 commit comments