vpopcntb

Vector Population Count Byte

vpopcntb vD, vB

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

Encoding

Binary Layout
4
0:5
vD
6:10
0
11:15
vB
16:20
1795
21:31
 
Format VX-form
Opcode 0x10000703
Extension VMX (AltiVec)

Operands

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

Example

vpopcntb vd, vb

Registers Altered

MSR

Related

More in VMX (AltiVec)

Reference

Description

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].

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.