Skip to contentSkip to conversation

ppc: Fix emulated INFINITY and NAN conversions

PATCH Applied Paul A. Clarke 3 participants 3 messages Aug 19, 2019 – Aug 20, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ppc: Fix emulated INFINITY and NAN conversions

From: "Paul A. Clarke" <[email protected]>

helper_todouble() was not properly converting INFINITY from 32 bit float to 64 bit double.

(Normalized operand conversion is unchanged, other than indentation.)

---
 target/ppc/fpu_helper.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
target/ppc/fpu_helper.c +11 -4
index 23b9c97..52bcda2 100644
@@ -58,10 +58,17 @@ uint64_t helper_todouble(uint32_t arg)
     uint64_t ret;
 
     if (likely(abs_arg >= 0x00800000)) {
-        /* Normalized operand, or Inf, or NaN.  */
-        ret  = (uint64_t)extract32(arg, 30, 2) << 62;
-        ret |= ((extract32(arg, 30, 1) ^ 1) * (uint64_t)7) << 59;
-        ret |= (uint64_t)extract32(arg, 0, 30) << 29;
+        if (unlikely(extract32(arg, 23, 8) == 0xff)) {
+            /* Inf or NAN.  */
+            ret  = (uint64_t)extract32(arg, 31, 1) << 63;
+            ret |= (uint64_t)0x7ff << 52;
+            ret |= (uint64_t)extract32(arg, 0, 23) << 29;
+        } else {
+            /* Normalized operand.  */
+            ret  = (uint64_t)extract32(arg, 30, 2) << 62;
+            ret |= ((extract32(arg, 30, 1) ^ 1) * (uint64_t)7) << 59;
+            ret |= (uint64_t)extract32(arg, 0, 30) << 29;
+        }
     } else {
         /* Zero or Denormalized operand.  */
         ret = (uint64_t)extract32(arg, 31, 1) << 63;
Signature · 1 line
1.8.3.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Paul A. Clarke

From: "Paul A. Clarke" <[email protected]>

helper_todouble() was not properly converting INFINITY from 32 bit float to 64 bit double.

(Normalized operand conversion is unchanged, other than indentation.)

---
 target/ppc/fpu_helper.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

r~

Applied
#2 lore raw
Quoted 6 lines · Richard Henderson
Quoted 5 lines · Paul A. Clarke

From: "Paul A. Clarke" <[email protected]>

helper_todouble() was not properly converting INFINITY from 32 bit float to 64 bit double.

Quoted 8 lines
Quoted 6 lines

(Normalized operand conversion is unchanged, other than indentation.)

---
 target/ppc/fpu_helper.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

Applied to ppc-for-4.2, thanks.

Quoted 4 lines

r~

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson