vsplth
Vector Splat Halfword
Duplicates a halfword element across the vector.
Details
Splats (replicates) a single halfword element from vB across all 8 halfword elements of vD. The halfword element selected is determined by the 3-bit unsigned immediate UIM (where UIM=0 selects halfword 0, UIM=7 selects halfword 7 in big-endian order). No status flags are affected. This is a VMX/AltiVec instruction.
Pseudocode Operation
index ← UIM
vD ← replicate(vB[index*16:index*16+15] to all 8 halfword positions)
Programming Note
The vsplth instruction is commonly used when you need to replicate a specific halfword from a source vector into all elements of a destination vector, which is useful for operations requiring uniform operands. Ensure the specified bit position (b) is within the valid range to avoid undefined behavior. This instruction operates at user privilege level and does not generate exceptions under normal circumstances.
Example
Encoding
Operands
-
vD
Target -
vB
Source -
UIM
Index