xvrdpi
VSX Vector Round to Double-Precision Integer using round to Nearest Away
xvrdpi XT,XB
Rounds each element of a double-precision floating-point vector to the nearest integer away from zero.
Encoding
Binary Layout
T
6:10
B
11:15
201
16:20
BX
21:25
TX
26:31
Operands
-
XT
Target Vector Register -
XB
Source Vector Register
Reference
View in PowerISA v3.1C Specification ↗
OPF Power ISA v3.1C
Description
For xvrdpi, each element in the source vector VSR[XB] is rounded to an integer using the rounding mode Round to Nearest Away. The result is placed into the target vector VSR[XT]. If a Signalling NaN is encountered, it is converted to a Quiet NaN and VXSNAN is set to 1.
Operation
if MSR.VSX=0 then VSX_Unavailable()
ex_flag ←0b0
do i = 0 to 1
reset_xflags()
src ←bfp_CONVERT_FROM_BFP64(VSR[32×BX+B].dword[i])
rnd ←bfp_ROUND_TO_INTEGER(0b100, src)
vresult.dword[i] ←bfp64_CONVERT_FROM_BFP(rnd)
if vxsnan_flag=1 then SetFX(FPSCR.VXSNAN)
ex_flag ←ex_flag | (FPSCR.VE & vxsnan_flag)
end
if ex_flag=0 then VSR[32×TX+T] ←vresult
Programming Note
This instruction is commonly used for converting floating-point numbers to integers with rounding towards the nearest integer away from zero. Ensure that the VSX (Vector Scalar Extensions) are enabled in the MSR register; otherwise, an exception will be raised. Be cautious of Signalling NaNs, as they are converted to Quiet NaNs and VXSNAN is set, which might affect subsequent operations if not handled properly.