ISARef Multi-ISA & Silicon Reference
45,419 ISA items · 105,907 timings · 1,761 microarchs · 16,083 chips · 105 sources
Arch:
Tier:

clzw

T1 riscv bitmanip insn
Count leading zero bits in word
SourceRISC-V Official Unified Database (riscv-unified-db) (riscv_unified_db)
Reliability TierT1 — Official Specification
ISA / Silicon ScopeRV32/RV64 Zbb
RV32 / RV64 (Ratified & Standard Extensions)
License & VersionApache-2.0 / CC-BY-4.0
main
Upstreamhttps://github.com/riscv/riscv-unified-db
Privilegeuser
ExtensionsZbb

Summary

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.

Syntax / Encoding

clzw xd, xs1 | 011000000000xxxxx001xxxxx0011011 (mask=0xfff0707f match=0x6000101b)

Cross-Chip Latency & Throughput (11 cores)

MicroarchitectureLatency (cycles)Recip. TPuopsPortsSource
SiFive P670 / P60010.251SiFiveP600IntArithllvm_sched_models
SiFive P870 / P80010.251SiFiveP800IntArithllvm_sched_models
SpacemiT X10010.251SMTX100_IQllvm_sched_models
SpacemiT X60 (K1)10.51SMX60_IEUllvm_sched_models
Syntacore SCR7111BMUllvm_sched_models
Tenstorrent Ascalon-X111AscalonFXllvm_sched_models
MIPS P8700 (RISC-V)211p8700IssueAL2llvm_sched_models
Andes 45-Series30.51Andes45ALUllvm_sched_models
SiFive 7-Series (U74)311PipeBllvm_sched_models
XiangShan KunMingHu30.51XSPipeGroupBKUllvm_sched_models
XiangShan NanHu30.51XS2MDUllvm_sched_models

Binary Encodings (1)

WidthFormatBit PatternMask / Match
32RV011000000000xxxxx001xxxxx00110110xfff0707f / 0x6000101b

Operands

NameDescription
xs1bits [19:15]
xdbits [11:7]

Reference Notes

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.