vperm

Vector Permute

vperm vD, vA, vB, vC

The signature AltiVec instruction. Constructs a new vector by selecting bytes from two source vectors based on a permute control vector.

Details

The Vector Permute instruction allows any byte in two source VSRs to be copied to any byte in the target VSR. The bytes in a third source VSR specify from which byte in the first two source VSRs the corresponding target byte is to be copied.

Pseudocode Operation

if MSR.VEC=0 then
    Vector_Unavailable()
vsrc.qword[0] ←VSR[VRA+32]
vsrc.qword[1] ←VSR[VRB+32]
do i = 0 to 15
    indexVSR[VRC+32].byte[i].bit[3:7]
    VSR[VRT+32].byte[i] ←src.byte[index]
end

Programming Note

See the Programming Notes with the Load Vector for Shift Left and Load Vector for Shift Right instructions on page 266 for examples of uses of vperm.

Example

vperm v1, v2, v3, v4

Encoding

Binary Layout
4
0
vD
6
vA
11
vB
16
vC
21
43
 
Format VA-form
Opcode 0x1000002B
Extension VMX (AltiVec)
Registers Altered MSR

Operands

  • vD
    Target
  • vA
    Source 1 (Bytes 0-15)
  • vB
    Source 2 (Bytes 16-31)
  • vC
    Control Vector
  • VRT
    Target Vector Register
  • VRA
    Source Vector Register
  • VRB
    Source Vector Register
  • VRC
    Permute Control Vector Register