`<bit>`: Use `_CountTrailingZeros[64]` for ARM64
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 11.2k
- Forks
- 1.7k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 22
Description
In VS 2022 17.7 Preview 3 (internal MSVC-PR-469248), our compiler back-end dev Jack Buchanan implemented new intrinsics in <intrin0.inl.h>:
__MACHINEARM_ARM64(unsigned int _CountTrailingZeros(unsigned long))
__MACHINEARM_ARM64(unsigned int _CountTrailingZeros64(unsigned __int64))
We should take advantage of them in <bit>'s countr_zero(), actually implemented in <limits> by _Countr_zero():
Similar to how we use _CountLeadingZeros[64] for countl_zero():
https://github.com/microsoft/STL/blob/5404ba9c25f26f25a0ac50e6c4defce7833a8da6/stl/inc/bit#L285-L306
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read stl/inc/limits around _Countr_zero() and compare the ARM64 handling in stl/inc/bit for countl_zero(). Check how the _CountTrailingZeros and _CountTrailingZeros64 intrinsics are exposed in intrin0.inl.h, then verify that ARM64 countr_zero() uses the matching paths without changing behavior on other targets.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- performance
- Issue type
- Refactor
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100