xxsel

VSX Vector Select

xxsel XT, XA, XB, XC

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

Details

The xxsel instruction selects elements from two source vectors (src1 and src2) based on the corresponding bits in a mask vector. If the bit in the mask is 0, the element from src1 is selected; if the bit is 1, the element from src2 is selected.

Pseudocode Operation

if MSR.VSX=0 then VSX_Unavailable()

src1 ←VSR[32×AX+A]
src2 ←VSR[32×BX+B]
mask ←VSR[32×CX+C]

VSR[32×TX+T] ←(src1 & ¬mask) | (src2 & mask)

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 0xF0000003
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