cnttzdm
Count Trailing Zeros Doubleword under Mask
cnttzdm RA, RS, RB
Counts trailing 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
571
21:30
/
31
Operands
-
RA
Target -
RS
Source -
RB
Mask -
RT
Target General Purpose Register
Reference
View in PowerISA v3.1C Specification ↗
OPF Power ISA v3.1C
Description
Counts the number of trailing 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 63 downto 0 do; if (masked_value[i] = 1) then break; count ← count + 1; RA ← count;
Programming Note
The cnttzdm instruction is useful for counting trailing zeros in a doubleword while applying a mask. Ensure that the mask register (RB) has bits set to 1 where you want to consider the corresponding bits in the source register (RS). The result is zero-extended to 64 bits before being stored in the destination register (RA). This instruction operates at user privilege level and does not generate any exceptions under normal conditions. Performance may vary based on the distribution of zeros and ones in the registers.