cntlzdm
Count Leading Zeros Doubleword under Mask
Counts leading zeros in RS, but only considering bits set in mask RB.
Details
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.
Pseudocode 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.
Example
Encoding
Operands
-
RA
Target -
RS
Source -
RB
Mask