Skip to content

[libc++] Replace uses of __libcpp_ctz by __countr_zero #131179

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
ldionne opened this issue Mar 13, 2025 · 0 comments · Fixed by #133920
Closed

[libc++] Replace uses of __libcpp_ctz by __countr_zero #131179

ldionne opened this issue Mar 13, 2025 · 0 comments · Fixed by #133920
Assignees
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.

Comments

@ldionne
Copy link
Member

ldionne commented Mar 13, 2025

For a follow-up patch, we should replace uses of __libcpp_ctz in the codebase by calls to __countr_zero (there's only a few). This will eventually allow us to clean up __libcpp_ctz altogether.

Originally posted by @ldionne in #122641 (comment)

@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Mar 13, 2025
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this issue May 6, 2025
…m#133920)

`__libcpp_{ctz, clz}` were previously used as fallbacks for `__builtin_{ctzg, clzg}` to ensure compatibility with older compilers (Clang 18 and earlier), as `__builtin_{ctzg, clzg}` became available in Clang 19. Now that support for Clang 18 has been officially dropped in llvm#130142, we can now safely  replace all instances of `__libcpp_{ctz, clz}` with `__count{l,r}_zero` (which internally call `__builtin_{ctzg, clzg}` and eliminate the fallback logic.

Closes llvm#131179.
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this issue May 6, 2025
…m#133920)

`__libcpp_{ctz, clz}` were previously used as fallbacks for `__builtin_{ctzg, clzg}` to ensure compatibility with older compilers (Clang 18 and earlier), as `__builtin_{ctzg, clzg}` became available in Clang 19. Now that support for Clang 18 has been officially dropped in llvm#130142, we can now safely  replace all instances of `__libcpp_{ctz, clz}` with `__count{l,r}_zero` (which internally call `__builtin_{ctzg, clzg}` and eliminate the fallback logic.

Closes llvm#131179.
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this issue May 6, 2025
…m#133920)

`__libcpp_{ctz, clz}` were previously used as fallbacks for `__builtin_{ctzg, clzg}` to ensure compatibility with older compilers (Clang 18 and earlier), as `__builtin_{ctzg, clzg}` became available in Clang 19. Now that support for Clang 18 has been officially dropped in llvm#130142, we can now safely  replace all instances of `__libcpp_{ctz, clz}` with `__count{l,r}_zero` (which internally call `__builtin_{ctzg, clzg}` and eliminate the fallback logic.

Closes llvm#131179.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
3 participants