xvmaxsp
VSX Vector Maximum Single-Precision
Computes the maximum of corresponding single-precision floating-point elements in two vector registers and stores the result in a third vector register.
Details
For xvmaxsp, the instruction compares each element of the source vectors VSR[XA] and VSR[XB] and places the larger value into the corresponding element of the target vector VSR[XT].
Pseudocode Operation
for i = 0 to 3 do
src1 <- VSR[XA][i]
src2 <- VSR[XB][i]
if isNaN(src1) or isNaN(src2) then
fx(VXSNAN)
T(Q(src2))
else if isInfinity(src1) and isInfinity(src2) and sign(src1) != sign(src2) then
fx(VXSNAN)
T(Q(src2))
else if isZero(src1) and isZero(src2) and sign(src1) != sign(src2) then
fx(VXSNAN)
T(Q(src2))
else
T(M(src1, src2))
end if
end for
Programming Note
The xvmaxsp instruction compares each element of two source vectors and stores the larger value in the target vector. It handles NaNs by setting VXSNAN in the FPSCR and transferring the quiet NaN to the result. Be cautious with infinities and zeros of opposite signs, as they also trigger VXSNAN. Ensure that the vectors are properly aligned for optimal performance.
Example
Encoding
Operands
-
XT
Target -
XA
Src A -
XB
Src B