[libcxx-commits] [libcxx] [libcxx] Use generic builtins for popcount, clz and ctz (PR #86563)

Marc Auberer via libcxx-commits libcxx-commits at lists.llvm.org
Tue Mar 26 06:29:24 PDT 2024


================
@@ -47,8 +59,13 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_clz(__uint128_t __x)
   // - Any bits set:
   //   - The number of leading zeros of the input is the number of leading
   //     zeros in the high 64-bits.
+#  if __has_builtin(__builtin_clzg)
+  return ((__x >> 64) == 0) ? (64 + __builtin_clzg(static_cast<unsigned long long>(__x)))
+                            : __builtin_clzg(static_cast<unsigned long long>(__x >> 64));
----------------
marcauberer wrote:

Done.

https://github.com/llvm/llvm-project/pull/86563


More information about the libcxx-commits mailing list