xxblendvw

VSX Vector Blend Variable Word

xxblendvw XT, XA, XB, XC

Selects words from XA or XB based on the MSB of words in XC.

Details

The xxblendvw instruction performs a vector blend operation on word elements. For each word element, if the least significant bit of the corresponding element in the third source register (XC) is 0, it selects the word from the first source register (XA); otherwise, it selects the word from the second source register (XB). The result is stored in the target register (XT).

Pseudocode Operation

if MSR.VSX=0 then VSX_Unavailable()
do i = 0 to 15
   if VSR[32×CX+C].word[i].bit[0]=0 then
      VSR[32×TX+T].word[i] ←VSR[32*AX+A].word[i]
   else
      VSR[32×TX+T].word[i] ←VSR[32*BX+B].word[i]
end

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

xxblendvw vs1, vs2, vs3, vs4

Encoding

Binary Layout
60
0
XT
6
XA
11
XB
16
XC
21
35
26
 
Format XX4-form
Opcode 0xF0000023
Extension VSX
Registers Altered MSR

Operands

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