Vectorized CLZ and CTZ
- October 9, 2026clz and ctz are instructions that compute the number of leading (trailing) zero bits in a fixed-size integer.
- They are natively supported by modern CPUs, though they are not always fast, e.g.
- I used ctz in an FPU emulator I’m working on, but figured out how to avoid it with floating-point trickery, and I just realized that this generalizes to a vectorizable ctz polyfill in a round-about way.
Unverified
- October 9, 2026clz and ctz are instructions that compute the number of leading (trailing) zero bits in a fixed-size integer.
- They are natively supported by modern CPUs, though they are not always fast, e.g.
- I used ctz in an FPU emulator I’m working on, but figured out how to avoid it with floating-point trickery, and I just realized that this generalizes to a vectorizable ctz polyfill in a round-about way.
Sources: Purplesyringa