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

Mark de Wever via libcxx-commits libcxx-commits at lists.llvm.org
Tue Mar 26 11:29:38 PDT 2024


================
@@ -25,15 +25,27 @@ _LIBCPP_PUSH_MACROS
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_clz(unsigned __x) _NOEXCEPT {
+#if __has_builtin(__builtin_clzg)
+  return __builtin_clzg(__x);
+#else
   return __builtin_clz(__x);
+#endif
----------------
mordante wrote:

I don't see a real win here. If we can use `__builtin_clzg` unconditionally in a few years we might be able to do more refactoring to remove several of these overloads.

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


More information about the libcxx-commits mailing list