File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -242,6 +242,14 @@ LIBC_INLINE constexpr To bit_or_static_cast(const From &from) {
242
242
// / Count number of 1's aka population count or Hamming weight.
243
243
// /
244
244
// / Only unsigned integral types are allowed.
245
+ // clang-19+, gcc-14+
246
+ #if __has_builtin(__builtin_popcountg)
247
+ template <typename T>
248
+ [[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t <cpp::is_unsigned_v<T>, int >
249
+ popcount (T value) {
250
+ return __builtin_popcountg (value);
251
+ }
252
+ #else // !__has_builtin(__builtin_popcountg)
245
253
template <typename T>
246
254
[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t <cpp::is_unsigned_v<T>, int >
247
255
popcount (T value) {
@@ -261,7 +269,7 @@ ADD_SPECIALIZATION(unsigned short, __builtin_popcount)
261
269
ADD_SPECIALIZATION(unsigned , __builtin_popcount)
262
270
ADD_SPECIALIZATION(unsigned long , __builtin_popcountl)
263
271
ADD_SPECIALIZATION(unsigned long long , __builtin_popcountll)
264
- // TODO: 128b specializations?
272
+ # endif // __builtin_popcountg
265
273
#undef ADD_SPECIALIZATION
266
274
267
275
} // namespace LIBC_NAMESPACE::cpp
You can’t perform that action at this time.
0 commit comments