[libcxx-commits] [libcxx] [libc++] Replace __libcpp_{ctz, clz} with __builtin_{ctzg, clzg} (PR #133920)
Peng Liu via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Apr 11 08:37:07 PDT 2025
================
@@ -45,12 +45,12 @@ struct _LIBCPP_HIDDEN __traits_base<_Tp, __enable_if_t<sizeof(_Tp) <= sizeof(uin
///
/// The algorithm is based on
/// http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog10
- /// Instead of using IntegerLogBase2 it uses __libcpp_clz. Since that
- /// function requires its input to have at least one bit set the value of
- /// zero is set to one. This means the first element of the lookup table is
- /// zero.
+ /// Instead of using IntegerLogBase2 it uses __countl_zero. Previously, it
+ /// used __libcpp_clz. Since that function requires its input to have at
----------------
winner245 wrote:
The old comment "Since that function requires its input to have at least one bit set" only applies to `__libcpp_c{l,t}z`, not to `__count{l,r}_zero`, because `__count{l,r}_zero` already handles all-zero inputs. In this case, since we are not using `__libcpp_c{l,t}z` any more, should I remove this comment completely?
https://github.com/llvm/llvm-project/pull/133920
More information about the libcxx-commits
mailing list