vslh
Vector Shift Left Halfword
vslh vD, vA, vB
Shifts each halfword left.
Details
Shifts each of the 8 halfword elements in vA left by a variable number of bits specified by the low 4 bits of the corresponding halfword element in vB. Bits shifted out are lost; positions vacated are filled with zeros. No status flags are affected. This is a VMX/AltiVec instruction.
Pseudocode Operation
for i ← 0 to 7 do
shift_amount ← vB[i*16:i*16+3]
vD[i*16:i*16+15] ← vA[i*16:i*16+15] << shift_amount
Programming Note
The vslh instruction shifts each halfword element of the source vector left by a specified number of bits. Ensure that the shift amount is within the valid range to avoid unexpected results. This instruction operates at the user privilege level and does not generate exceptions under normal conditions.
Example
vslh vd, va, vb
Encoding
Binary Layout
4
0
vD
6
vA
11
vB
16
324
21
Operands
-
vD
Target -
vA
Data -
vB
Shift