vpopcntd

Vector Population Count Doubleword

vpopcntd vD, vB

Counts set bits in each doubleword.

Details

Counts the number of set bits (population count) in each of the 2 doubleword elements in vB and stores the result in the corresponding doubleword of vD. Each result is an unsigned integer in the range 0–64. No status flags are affected. This instruction is part of the VMX (AltiVec) extension.

Pseudocode Operation

for i in 0 to 1 do
  count ← 0
  doubleword ← vB[i*64 : i*64+63]
  for j in 0 to 63 do
    if doubleword[j] = 1 then
      count ← count + 1
  vD[i*64 : i*64+63] ← count

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