← Back to events
ActiveTech

Vectorized CLZ and CTZ

Photo: Lobsters

What happened

clz 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. tzcnt has a latency of 3 on Arrow Lake. 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 r…

Summary assembled by rule from the sources below

Why it's spreading

Sources

Community