xsrqpi

VSX Scalar Round Quad-Precision to Integer

xsrqpi vD, vB, R

Rounds a quad-precision floating-point value in VRB to an integer and places the result in VRT.

Details

The xsrqpi instruction rounds a quad-precision floating-point value in VRB to an integer using the specified rounding mode RMC. The result is placed into VSR[VRT+32] in quad-precision format. If EX=1, it also sets flags for inexact exceptions.

Pseudocode Operation

if MSR.VSX=0 then VSX_Unavailable()
reset_xflags()
if R=0 then do
    if RMC=0b00 then rmode ←0b100
    if RMC=0b11 then do
        if FPSCR.RN=0b00 then rmode ←0b000
        if FPSCR.RN=0b01 then rmode ←0b001
        if FPSCR.RN=0b10 then rmode ←0b010
        if FPSCR.RN=0b11 then rmode ←0b011
    end
end else do // R=1
    if RMC=0b00 then rmode ←0b000
    if RMC=0b01 then rmode ←0b001
    if RMC=0b10 then rmode ←0b010
    if RMC=0b11 then rmode ←0b011
end
src ←bfp_CONVERT_FROM_BFP128(VSR[VRB+32])
if src.class.SNaN then do
    result ←bfp128_CONVERT_FROM_BFP(bfp_QUIET(src))
    vxsnan_flag ←1
end else if src.class.QNaN | src.class.Infinity | src.class.Zero then
    result ←bfp128_CONVERT_FROM_BFP(src)
else do
    rnd ←bfp_ROUND_TO_INTEGER(rmode, src)
    result ←bfp128_CONVERT_FROM_BFP(rnd)
end
if vxsnan_flag=1 then SetFX(FPSCR.VXSNAN)
if xx_flag & EX then SetFX(FPSCR.XX)
vex_flag ←FPSCR.VE & vxsnan_flag
if vex_flag=0 then do
    VSR[VRT+32] ←result
    FPSCR.FPRF ←fprf_CLASS_BFP128(result)
end
FPSCR.FI ←EX & (vxsnan_flag=0) & xx_flag

Programming Note

The xsrqpi instruction is used to round a quad-precision floating-point value to an integer. Ensure that the VSX feature is enabled in the MSR register. Be cautious with NaN values, as they can trigger exceptions and set specific flags. The rounding mode is determined by the RMC field and the FPSCR.RN setting when R=0.

Example

xsrqpi vd, vb, 0

Encoding

Binary Layout
63
0
VRT
16
VRB
21
RMC
23
EX
30
R
31
 
Format Z23-form
Opcode 0xFC000005
Extension VSX
Registers Altered FPSCR, VXSNAN, FX

Operands

  • vD
    Target
  • vB
    Source
  • R
    Mode
  • VRT
    Target Vector Register
  • VRB
    Source Vector Register
  • RMC
    Rounding Mode Control