vrlwmi

Vector Rotate Left Word then Mask Insert VX-form

vrlwmi VRT,VRA,VRB

Rotates the contents of each word element in a vector left by a specified number of bits and inserts the result into another vector under control of a mask.

Details

The vrlwmi instruction rotates each word element in VSR[VRA+32] left by the number of bits specified in the corresponding word element of VSR[VRB+32]. It then inserts the rotated data into the corresponding word element of VSR[VRT+32] under control of a mask generated from bits 11:15 and 19:23 of VSR[VRB+32].

Pseudocode Operation

if MSR.VEC=0 then
    Vector_Unavailable()
do i = 0 to 3
    src1.word[0] ← VSR[VRA+32].word[i]
    src1.word[1] ← VSR[VRA+32].word[i]
    src2 ← VSR[VRB+32].word[i]
    src3 ← VSR[VRT+32].word[i]
    b ← src2.bit[11:15]
    e ← src2.bit[19:23]
    n ← src2.bit[27:31]
    r ← src1.bit[n:n+31]
    m ← MASK(b, e)
    VSR[VRT+32].word[i] ← (r & m) | (src3 & ¬m)

Programming Note

The vrlwmi instruction is useful for performing masked insertions after rotating word elements. Ensure that the mask bits (11:15 and 19:23) are set correctly to achieve the desired insertion pattern. This instruction operates on vector registers, so ensure that the Vector Facility is enabled in the Machine State Register (MSR).

Example

vrlwmi v1, v2, v3

Encoding

Binary Layout
4
0
VRT
6
VRA
11
VRB
16
 
Format VX-form
Opcode 0x10000085
Extension VMX (AltiVec)

Operands

  • VRT
    Target Vector Register
  • VRA
    Source Vector Register
  • VRB
    Source Vector Register