Chapter 2. Programming Model
2-83
AltiVec UISA Instructions
2.5.5.5 Vector Permute Instructions
Permute instructions allow any byte in any two source VRs to be directed to any byte in the
destination vector. The Telds in a third source operand specify from which Teld in the
source operands the corresponding destination Teld is taken. The Vector Permute (
vperm
)
instruction is a very powerful one that provides many useful functions. For example, it
provides a way to perform table-lookups and data alignment operations. An example of
how to use the
vperm
instruction in aligning data is described in òQuad-Word Data
Alignment,ó in Chapter 3, òOperand Conventions,ó of
The AltiVec Technology
Programming Environments Manual
. Table 2-72 describes the vector permute instruction.
2.5.5.6 Vector Select Instruction
Data ow in the vector unit can be controlled without branching by using a vector compare
and the Vector Select (
vsel
) instructions. In this use, the compare result vector is used
directly as a mask operand to vector select instructions.The
vsel
instruction selects one Teld
from one or the other of two source operands under control of its mask operand. Use of the
TRUE/FALSE compare result vector with select in this manner produces a two instruction
equivalent of conditional execution on a per-Teld basis. Table 2-77 describes the
vsel
instruction.
2.5.5.7 Vector Shift Instructions
The vector shift instructions shift the contents of a VR, or of a pair of VRs, left or right by
a speciTed number of bytes (
vslo
,
vsro
,
vsldoi
) or bits (
vsl
,
vsr
). Depending on the
instruction, this shift count is speciTed either by low-order bits of a VR or by an immediate
Teld in the instruction. In the former case the low-order 7 bits of the shift count register give
the shift count in bits (0
£
count
£
127). Of these 7 bits, the high-order 4 bits give the
Table 2-75. Vector Splat Instructions
Name
Mnemonic
Syntax
Vector Splat Integer
vspltb
vsplth
vspltw
v
D,
v
B, UIMM
Vector Splat Immediate Signed Integer
vspltisb
vspltish
vspltisw
v
D, SIMM
Table 2-76. Vector Permute Instruction
Name
Mnemonic
Syntax
Vector Permute
vperm
v
D
, v
A
,v
B
,v
C
Table 2-77. Vector Select Instruction
Name
Mnemonic
Syntax
Vector Select
vsel
v
D
,v
A
,v
B,
v
C