cntlzdm
Count Leading Zeros Doubleword under Mask
cntlzdm RA, RS, RB
Counts leading zeros in RS, but only considering bits set in mask RB.
Encoding
Binary Layout
31
0:5
RS
6:10
RA
11:15
RB
16:20
59
21:30
/
31
Operands
-
RA
Target -
RS
Source -
RB
Mask
Example
cntlzdm r4, r3, r5
Related
More in Base
Reference
View in PowerISA v3.1C Specification ↗
OPF Power ISA v3.1C
Description
Counts the number of leading zeros in RS considering only the bit positions set to 1 in the mask RB (Power10 Scalar). The count is placed in RA. No CR, XER, or FPSCR fields are affected.
Operation
mask ← RB; masked_value ← RS ∧ mask; if (masked_value = 0) then RA ← 64; else count ← 0; for i in 0 to 63 do; if (masked_value[i] = 1) then break; count ← count + 1; RA ← count;
Programming Note
The cntlzdm instruction is useful for counting leading zeros in a doubleword while considering only the bits that are set to 1 in a mask. Ensure that both the source and mask registers are correctly aligned and that the mask register has at least one bit set to 1 to avoid undefined behavior. This instruction operates at user privilege level and does not generate exceptions under normal conditions, but it may incur performance penalties on processors without hardware support for this operation.