← Home

clzw

Count leading zero bits in word

Counts the number of 0's before the first 1 starting at bit 31 and progressing to bit 0. Accordingly, if the least-significant word is 0, the output is 32, and if the most-significant bit of the word (_i.e._, bit 31) is a 1, the output is 0.

Assembly format

clzw xd, xs1

Encoding

313029282726252423222120191817161514131211109876543210
011000000000xs1001xd0011011

Decode variables

VariableBitsWidth
xs1[19:15]5
xd[11:7]5

Execution

X[xd] = 31 - $signed(highest_set_bit(X[xs1][31:0]));

Defined by

RV64 and Zbb

Access

SUVSVU
AlwaysAlwaysAlwaysAlways

Version af3eaf9+cheriot.f635218

Data from the RISC-V Unified Database, copyright RISC-V International and contributors.

CHERIoT extensions from the CHERIoT specification and Sail model, copyright Microsoft and the CHERIoT Platform contributors.

This site is provided as a community resource and is NOT affiliated with nor endorsed by RISC-V International.