vcntmbw
Vector Count Mask Bits Word
Counts the number of word elements in a vector register that have bit 0 set to a specified value.
Details
Counts the number of word elements in VRB that have bit 0 set to the value specified by MP (0 or 1), and places the count in the leftmost byte of the target GPR RT. This instruction is part of the VMX category and does not affect condition registers or status fields.
Pseudocode Operation
count ← 0
for i in 0 to 3:
if (VRB.word[i][0] == MP) then
count ← count + 1
RT[56:63] ← count
RT[0:55] ← 0
Programming Note
The vcntmbw instruction is useful for counting the number of word elements in a vector register that have their least significant bit set to a specified value. Ensure that the Vector Facility (MSR.VEC) is enabled before using this instruction; otherwise, it will raise an exception. The result is stored in the upper bits of the target GPR, so be cautious when interpreting the output.
Example
Encoding
Operands
-
RT
Target General Purpose Register -
VRB
Source Vector Register -
MP
Mask Bit Value