vpopcntb

Vector Population Count Byte

vpopcntb vD, vB

Counts the number of bits set to 1 in each byte of a vector register.

Details

For vpopcntb, the number of bits set to 1 in each byte element of VSR[VRB+32] is counted and placed into the corresponding byte element of VSR[VRT+32].

Pseudocode Operation

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

Programming Note

This instruction is used to count the number of set bits (1s) in each byte of a vector register. Ensure that the Vector Facility is enabled by checking and setting the VEC bit in the MSR register. The operation processes 16 bytes, and the result is stored in another vector register. This instruction is available at user privilege level.

Example

vpopcntb vd, vb

Encoding

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

Operands

  • vD
    Target
  • vB
    Source
  • VRT
    Target Vector Register
  • VRB
    Source Vector Register