Count Leading Zeros

Count zero bits above the most significant set bit.

Bit Manipulation

Semantics

rd = clz(rs1). Note the semantic split: true CLZ counts leading zeros, while x86's older BSR returns the INDEX of the highest set bit and leaves the destination undefined for a zero input.

Architecture Instructions Expressed as How this architecture does it
x86 one instruction Two different operations that are easy to confuse: LZCNT (BMI1/ABM) counts leading zeros and is defined for a zero input, while the older BSR returns the bit INDEX of the highest set bit and leaves the destination undefined when the source is zero.
ARM one instruction Base instruction, defined to return the register width for a zero input.
RISC-V one instruction Zbb extension, defined to return XLEN for a zero input like ARM's, so no special case is needed. CLZW gives the 32-bit count on RV64.
PowerISA one instruction Base instruction in both 64-bit and 32-bit forms.