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

Nick Desaulniers via libcxx-commits libcxx-commits at lists.llvm.org
Mon Mar 25 14:20:15 PDT 2024


nickdesaulniers wrote:

> What benefit does this change have?

I suspect it would be possible to omit most of the content of libcxx/include/__bit/countl.h, libcxx/include/__bit/countr.h, and libcxx/include/__bit/popcount.h when this builtin is defined.

The current PR is perhaps too granular in its use of __has_builtin checks.  For example, take the `__libcpp_clz` case. `__libcpp_clz` need not even be defined when the type generic builtin exists. Callers of __libcpp_clz could be updated to just call `__countl_zero`.

That would allow the preprocessor/lexer and Sema to do less work when these builtins exist.  Is that worth the change here? I'll leave that to libc++ maintainers to make a call.

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


More information about the libcxx-commits mailing list