vbpermq

Vector Bit Permute Quadword

vbpermq VRT,VRA,VRB

Performs a bit permutation on two vector registers and stores the result in another vector register.

Details

The vbpermq instruction permutes bits from two source vector registers (VRA and VRB) based on the index values provided in VRB and stores the result in VRT. If an index value is less than 128, it selects the corresponding bit from VRA; otherwise, it sets the bit to 0.

Pseudocode Operation

if MSR.VEC=0 then
    Vector_Unavailable()
do i = 0 to 15
    indexVSR[VRB+32].byte[i]
    if index < 128 then
        perm.bit[i] ←VSR[VRA+32].bit[index]
    else
        perm.bit[i] ←0
end
VSR[VRT+32].dword[0] ←CHOP64(EXTZ(perm))
VSR[VRT+32].dword[1] ←0x0000_0000_0000_0000

Programming Note

The fact that the permuted bit is 0 if the corresponding index value exceeds 127 permits the permuted bits to be selected from a 256-bit quantity, using a single index register.

Example

vbpermq v1, v2, v3

Encoding

Binary Layout
1001
0
VRT
6
VRA
11
VRB
16
10000000000000000000000000000000
21
 
Format VX-form
Opcode 0x1000054C
Extension VMX (AltiVec)
Registers Altered MSR

Operands

  • VRT
    Target Vector Register
  • VRA
    Source Vector Register
  • VRB
    Index Source Vector Register