fix fcvttg* overflow/FPSCR computation
authorJacob Lifshay <programmerjake@gmail.com>
Tue, 16 May 2023 06:50:52 +0000 (23:50 -0700)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 2 Jun 2023 18:51:18 +0000 (19:51 +0100)
openpower/isa/fpcvt.mdwn

index 27bd09a57b99de5d6d4c0bb2ec3263dfd4e3572e..d25ba9cde097029494325eb7800306ec1cef9c02 100644 (file)
@@ -186,19 +186,23 @@ Pseudo-code:
             result_bfp <- bfp_CONVERT_FROM_SI64(result)
         default:  # Unsigned 64-bit
             result_bfp <- bfp_CONVERT_FROM_UI64(result)
+    overflow <- 0
+    if IsNaN(src) | ¬bfp_COMPARE_EQ(rnd, result_bfp) then
+        overflow <- 1  # signals SO only when OE = 1
+        vxcvi_flag <- 1
+        xx_flag <- 0
+    else if ¬bfp_COMPARE_EQ(src, result_bfp) then
+        xx_flag <- 1
     if vxsnan_flag = 1 then SetFX(FPSCR.VXSNAN)
     if vxcvi_flag = 1 then SetFX(FPSCR.VXCVI)
     if xx_flag = 1 then SetFX(FPSCR.XX)
     vx_flag <- vxsnan_flag | vxcvi_flag
     vex_flag <- FPSCR.VE & vx_flag
-    overflow <- 0
     if vex_flag = 0 then
         RT <- result
         FPSCR.FPRF <- undefined(0b00000)
         FPSCR.FR <- inc_flag
         FPSCR.FI <- xx_flag
-        if IsNaN(src) | ¬bfp_COMPARE_EQ(src, result_bfp) then
-            overflow <- 1  # signals SO only when OE = 1
     else
         FPSCR.FR <- 0
         FPSCR.FI <- 0
@@ -296,19 +300,23 @@ Pseudo-code:
             result_bfp <- bfp_CONVERT_FROM_SI64(result)
         default:  # Unsigned 64-bit
             result_bfp <- bfp_CONVERT_FROM_UI64(result)
+    overflow <- 0
+    if IsNaN(src) | ¬bfp_COMPARE_EQ(rnd, result_bfp) then
+        overflow <- 1  # signals SO only when OE = 1
+        vxcvi_flag <- 1
+        xx_flag <- 0
+    else if ¬bfp_COMPARE_EQ(src, result_bfp) then
+        xx_flag <- 1
     if vxsnan_flag = 1 then SetFX(FPSCR.VXSNAN)
     if vxcvi_flag = 1 then SetFX(FPSCR.VXCVI)
     if xx_flag = 1 then SetFX(FPSCR.XX)
     vx_flag <- vxsnan_flag | vxcvi_flag
     vex_flag <- FPSCR.VE & vx_flag
-    overflow <- 0
     if vex_flag = 0 then
         RT <- result
         FPSCR.FPRF <- undefined(0b00000)
         FPSCR.FR <- inc_flag
         FPSCR.FI <- xx_flag
-        if IsNaN(src) | ¬bfp_COMPARE_EQ(src, result_bfp) then
-            overflow <- 1  # signals SO only when OE = 1
     else
         FPSCR.FR <- 0
         FPSCR.FI <- 0