xxblendvw
VSX Vector Blend Variable Word
Selects words from XA or XB based on the MSB of words in XC.
Details
Selects whole words from XA or XB based on the MSB of the corresponding word in control register XC. If the MSB of a word in XC is 1, the word from XB is selected; otherwise the word from XA is selected. This VSX instruction does not affect condition registers or status fields.
Pseudocode Operation
for i in 0 to 3:
if XC[32*i] == 1:
XT[32*i:32*i+31] ← XB[32*i:32*i+31]
else:
XT[32*i:32*i+31] ← XA[32*i:32*i+31]
Programming Note
The xxblendvw instruction is commonly used for conditional blending of word elements from two source vectors based on a control vector. Ensure that the VSX (Vector Scalar Extensions) are enabled in the MSR register to avoid exceptions. This instruction operates on 16-word elements, so alignment and ordering of input registers must be correct to prevent data corruption or incorrect results.
Example
Encoding
Operands
-
XT
Target -
XA
Src A -
XB
Src B -
XC
Control