vpopcntd

Vector Population Count Doubleword

vpopcntd vD, vB

Counts set bits in each doubleword.

Details

The vpopcntd instruction counts the number of bits set to 1 in each doubleword element of a vector register and stores the result in another vector register. The operation is performed on each of the two doublewords (64-bit elements) in the source vector, and the results are stored in the corresponding positions in the destination vector.

Pseudocode Operation

if MSR.VEC=0 then Vector_Unavailable()
do i = 0 to 1
   n ←0
   do j = 0 to 63
      n ←n + VSR[VRB+32].dword[i].bit[j]
   end
   VSR[VRT+32].dword[i] ←n
end

Programming Note

The vpopcntd instruction is useful for counting the number of set bits in each 64-bit element of a vector. Ensure that the Vector Facility (MSR.VEC) is enabled before using this instruction; otherwise, it will raise an exception. This instruction operates on two doublewords per vector register, and results are stored in the corresponding positions of the destination vector.

Example

vpopcntd vd, vb

Encoding

Binary Layout
4
0
vD
6
0
11
vB
16
1987
21
 
Format VX-form
Opcode 0x100007C3
Extension VMX (AltiVec)
Registers Altered MSR

Operands

  • vD
    Target
  • vB
    Source