xxsel

VSX Vector Select

xxsel XT, XA, XB, XC

Selects elements from two source vectors based on a mask vector.

Details

Selects bits from XA or XB for each bit position based on the corresponding bit in the mask register XC. Where XC has a 1 bit, the result takes the bit from XA; where XC has a 0 bit, the result takes the bit from XB. This is a VSX instruction with no effect on condition or status flags.

Pseudocode Operation

for i in 0 to 127 do
  if XC[i] = 1 then
    XT[i] ← XA[i]
  else
    XT[i] ← XB[i]

Programming Note

The xxsel instruction is commonly used for conditional vector selection based on a mask. Ensure that the VSX feature is enabled in the MSR register to avoid an exception. The source and destination vectors must be properly aligned, typically requiring 16-byte alignment for optimal performance.

Example

xxsel vs1, vs2, vs3, vs4

Encoding

Binary Layout
60
6
XT
11
XA
16
XB
21
XC
26
3
28 29 30 31
 
Format XX4-form
Opcode 0xF0000030
Extension VSX
Registers Altered MSR

Operands

  • XT
    Target
  • XA
    True Src
  • XB
    False Src
  • XC
    Mask
  • VRT
    Target Vector Register
  • VRA
    Source Vector Register
  • VRB
    Source Vector Register
  • VRC
    Source Vector Register