xxpermr

VSX Vector Permute Right

xxpermr XT, XA, XB, XC

Little-endian optimized permute.

Details

The VSX Vector Permute Right instruction (xxpermr) permutes bytes from two source vectors based on a control vector. It places the first 16 bytes of the first source vector into the lower half of the target vector and uses the control vector to determine how to place the remaining 16 bytes from the second source vector into the upper half of the target vector, with an additional right-indexed twist.

Pseudocode Operation

Let XA be the value 32×AX + A.
Let XB be the value 32×BX + B.
Let XT be the value 32×TX + T.

src.byte[0:15] ← VSR[XA]
src.byte[16:31] ← VSR[XT]
pcv.byte[0:15] ← VSR[XB]

do i = 0 to 15
   idx ← pcv.byte[i].bit[3:7]
   VSR[XT].byte[i] ← src.byte[31-idx]
end

Programming Note

The xxpermr instruction is useful for complex byte-level data manipulation, especially when merging and reordering bytes from two source vectors. Ensure that the control vector (second source) correctly specifies the desired permutation indices to avoid unexpected results. This instruction operates at a privilege level that allows it in user mode, but developers should be cautious of potential performance overhead due to its complexity.

Example

xxpermr vs1, vs2, vs3, vs4

Encoding

Binary Layout
60
0
XT
6
XA
11
XB
16
XC
21
58
26
 
Format XX4-form
Opcode 0xF000003A
Extension VSX

Operands

  • XT
    Target
  • XA
    Src A
  • XB
    Src B
  • XC
    Control