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.

Details

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.

Pseudocode 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.

Example

xvrdpi vs1, vs3

Encoding

Binary Layout
T
6
B
11
201
16
BX
21
TX
26
 
Format XX2-form
Opcode 0xF0000324
Extension VSX
Registers Altered FPSCR, VXSNAN

Operands

  • XT
    Target Vector Register
  • XB
    Source Vector Register