fix bug in fcvttg OpenPower and saturating conversion
authorJacob Lifshay <programmerjake@gmail.com>
Wed, 17 May 2023 04:52:52 +0000 (21:52 -0700)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 2 Jun 2023 18:51:18 +0000 (19:51 +0100)
openpower/isa/fpcvt.mdwn

index 68fb0bf31f18ba0f5d587e3b7bde5058aa39da3a..0d2b859f245e731ec18788b8c151699cdc13f791 100644 (file)
@@ -147,9 +147,9 @@ Pseudo-code:
             else if bfp_COMPARE_LT(rnd, range_min) then
                 result <- si64_CONVERT_FROM_BFP(range_min)
             else if IT[1] = 1 then  # Unsigned 32/64-bit
-                result <- ui64_CONVERT_FROM_BFP(range_max)
+                result <- ui64_CONVERT_FROM_BFP(rnd)
             else  # Signed 32/64-bit
-                result <- si64_CONVERT_FROM_BFP(range_max)
+                result <- si64_CONVERT_FROM_BFP(rnd)
         case(2, 3):  # Java/Saturating semantics
             if IsNaN(rnd) then
                 result <- [0] * 64
@@ -158,9 +158,9 @@ Pseudo-code:
             else if bfp_COMPARE_LT(rnd, range_min) then
                 result <- si64_CONVERT_FROM_BFP(range_min)
             else if IT[1] = 1 then  # Unsigned 32/64-bit
-                result <- ui64_CONVERT_FROM_BFP(range_max)
+                result <- ui64_CONVERT_FROM_BFP(rnd)
             else  # Signed 32/64-bit
-                result <- si64_CONVERT_FROM_BFP(range_max)
+                result <- si64_CONVERT_FROM_BFP(rnd)
         default:  # JavaScript semantics
             # CVM = 6, 7 are illegal instructions
             # using a 128-bit intermediate works here because the largest type
@@ -262,9 +262,9 @@ Pseudo-code:
             else if bfp_COMPARE_LT(rnd, range_min) then
                 result <- si64_CONVERT_FROM_BFP(range_min)
             else if IT[1] = 1 then  # Unsigned 32/64-bit
-                result <- ui64_CONVERT_FROM_BFP(range_max)
+                result <- ui64_CONVERT_FROM_BFP(rnd)
             else  # Signed 32/64-bit
-                result <- si64_CONVERT_FROM_BFP(range_max)
+                result <- si64_CONVERT_FROM_BFP(rnd)
         case(2, 3):  # Java/Saturating semantics
             if IsNaN(rnd) then
                 result <- [0] * 64
@@ -273,9 +273,9 @@ Pseudo-code:
             else if bfp_COMPARE_LT(rnd, range_min) then
                 result <- si64_CONVERT_FROM_BFP(range_min)
             else if IT[1] = 1 then  # Unsigned 32/64-bit
-                result <- ui64_CONVERT_FROM_BFP(range_max)
+                result <- ui64_CONVERT_FROM_BFP(rnd)
             else  # Signed 32/64-bit
-                result <- si64_CONVERT_FROM_BFP(range_max)
+                result <- si64_CONVERT_FROM_BFP(rnd)
         default:  # JavaScript semantics
             # CVM = 6, 7 are illegal instructions
             # using a 128-bit intermediate works here because the largest type