vsubsws
Vector Subtract Signed Word Saturate
Subtracts 4 signed words with saturation.
Details
Subtracts each of 4 signed 32-bit elements in vB from the corresponding element in vA, with saturation to the signed 32-bit range [-2147483648, 2147483647]. If overflow or underflow occurs, the result saturates to the minimum or maximum signed word value. No condition register fields are affected.
Pseudocode Operation
for i in 0 to 3 do
result ← vA[32*i:32*i+31] - vB[32*i:32*i+31]
if result < -2147483648 then vD[32*i:32*i+31] ← -2147483648
elsif result > 2147483647 then vD[32*i:32*i+31] ← 2147483647
else vD[32*i:32*i+31] ← result
Programming Note
The vsubsws instruction is useful for performing vectorized subtraction of signed words with saturation, ensuring that results do not overflow. Ensure that the VEC bit in the MSR register is set to enable vector operations; otherwise, a Vector_Unavailable exception will be raised. Be aware that the SAT flag in the VSCR register indicates if any result was saturated during the operation.
Example
Encoding
Operands
-
vD
Target -
vA
Src A -
vB
Src B