File tree Expand file tree Collapse file tree 3 files changed +38
-10
lines changed Expand file tree Collapse file tree 3 files changed +38
-10
lines changed Original file line number Diff line number Diff line change @@ -68,15 +68,25 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_clz(__uint128_t __x)
68
68
}
69
69
#endif // _LIBCPP_HAS_NO_INT128
70
70
71
+ #if __has_builtin(__builtin_clzg)
72
+
71
73
template <class _Tp >
72
74
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int __countl_zero (_Tp __t ) _NOEXCEPT {
73
75
static_assert (__libcpp_is_unsigned_integer<_Tp>::value, " __countl_zero requires an unsigned integer type" );
74
76
if (__t == 0 )
75
77
return numeric_limits<_Tp>::digits;
76
78
77
- #if __has_builtin(__builtin_clzg)
78
79
return __builtin_clzg (__t ) - (numeric_limits<unsigned >::digits - numeric_limits<_Tp>::digits);
79
- #else
80
+ }
81
+
82
+ #else // __has_builtin(__builtin_clzg)
83
+
84
+ template <class _Tp >
85
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int __countl_zero (_Tp __t ) _NOEXCEPT {
86
+ static_assert (__libcpp_is_unsigned_integer<_Tp>::value, " __countl_zero requires an unsigned integer type" );
87
+ if (__t == 0 )
88
+ return numeric_limits<_Tp>::digits;
89
+
80
90
if (sizeof (_Tp) <= sizeof (unsigned int ))
81
91
return std::__libcpp_clz (static_cast <unsigned int >(__t )) -
82
92
(numeric_limits<unsigned int >::digits - numeric_limits<_Tp>::digits);
@@ -98,9 +108,10 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int __countl_zero(_Tp __t) _
98
108
}
99
109
return __ret + __iter;
100
110
}
101
- #endif // __has_builtin(__builtin_clzg)
102
111
}
103
112
113
+ #endif // __has_builtin(__builtin_clzg)
114
+
104
115
#if _LIBCPP_STD_VER >= 20
105
116
106
117
template <__libcpp_unsigned_integer _Tp>
Original file line number Diff line number Diff line change @@ -47,14 +47,23 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_ct
47
47
#endif
48
48
}
49
49
50
+ #if __has_builtin(__builtin_ctzg)
51
+
50
52
template <class _Tp >
51
53
_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int __countr_zero (_Tp __t ) _NOEXCEPT {
52
54
if (__t == 0 )
53
55
return numeric_limits<_Tp>::digits;
54
56
55
- #if __has_builtin(__builtin_ctz)
56
57
return __builtin_ctz (__t );
57
- #else
58
+ }
59
+
60
+ #else // __has_builtin(__builtin_ctzg)
61
+
62
+ template <class _Tp >
63
+ _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int __countr_zero (_Tp __t ) _NOEXCEPT {
64
+ if (__t == 0 )
65
+ return numeric_limits<_Tp>::digits;
66
+
58
67
if (sizeof (_Tp) <= sizeof (unsigned int ))
59
68
return std::__libcpp_ctz (static_cast <unsigned int >(__t ));
60
69
else if (sizeof (_Tp) <= sizeof (unsigned long ))
@@ -70,9 +79,10 @@ _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int __coun
70
79
}
71
80
return __ret + std::__libcpp_ctz (static_cast <unsigned long long >(__t ));
72
81
}
73
- #endif // __has_builtin(__builtin_ctz)
74
82
}
75
83
84
+ #endif // __has_builtin(__builtin_ctzg)
85
+
76
86
#if _LIBCPP_STD_VER >= 20
77
87
78
88
template <__libcpp_unsigned_integer _Tp>
Original file line number Diff line number Diff line change @@ -49,11 +49,17 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_popcount(unsigned lo
49
49
50
50
#if _LIBCPP_STD_VER >= 20
51
51
52
+ # if __has_builtin(__builtin_popcountg)
53
+
54
+ template <__libcpp_unsigned_integer _Tp>
55
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr int popcount (_Tp __t ) noexcept {
56
+ return __builtin_popcountg (__t );
57
+ }
58
+
59
+ # else // __has_builtin(__builtin_popcountg)
60
+
52
61
template <__libcpp_unsigned_integer _Tp>
53
62
_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
57
63
if (sizeof (_Tp) <= sizeof (unsigned int ))
58
64
return std::__libcpp_popcount (static_cast <unsigned int >(__t ));
59
65
else if (sizeof (_Tp) <= sizeof (unsigned long ))
@@ -68,9 +74,10 @@ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr int popcount(_Tp __t) noex
68
74
}
69
75
return __ret;
70
76
}
71
- # endif // __has_builtin(__builtin_popcount)
72
77
}
73
78
79
+ # endif // __has_builtin(__builtin_popcountg)
80
+
74
81
#endif // _LIBCPP_STD_VER >= 20
75
82
76
83
_LIBCPP_END_NAMESPACE_STD
You can’t perform that action at this time.
0 commit comments