xxsel
VSX Vector Select
xxsel XT, XA, XB, XC
Selects elements from two source vectors based on a mask vector.
Encoding
Binary Layout
60
XT
XA
XB
XC
3
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
Reference
View in PowerISA v3.1C Specification ↗
OPF Power ISA v3.1C
Description
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.
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.