fix fcvttg* overflow/FPSCR computation
authorJacob Lifshay <programmerjake@gmail.com>
Tue, 16 May 2023 06:53:00 +0000 (23:53 -0700)
committerJacob Lifshay <programmerjake@gmail.com>
Tue, 16 May 2023 06:53:00 +0000 (23:53 -0700)
openpower/sv/int_fp_mv/moves_and_conversions.mdwn

index 203f37d99dd9125968d9d8c2284e0451613a0384..8afc3c65ae10cd51cd47acca8f6ea84585616467 100644 (file)
@@ -553,21 +553,25 @@ Section 7.1 of the ECMAScript / JavaScript
         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
         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
@@ -713,21 +717,25 @@ Special Registers altered:
         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
         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