summaryrefslogtreecommitdiffstats
path: root/target
diff options
context:
space:
mode:
authorPaul A. Clarke2019-08-19 21:19:48 +0200
committerDavid Gibson2019-08-21 09:17:39 +0200
commita7b7b98318f7d483e016f0f412df2b8a7dc1d636 (patch)
treec746a6a0ba1e27e60daf8860625a0be1ee7f990d /target
parentppc: conform to processor User's Manual for xscvdpspn (diff)
downloadqemu-a7b7b98318f7d483e016f0f412df2b8a7dc1d636.tar.gz
qemu-a7b7b98318f7d483e016f0f412df2b8a7dc1d636.tar.xz
qemu-a7b7b98318f7d483e016f0f412df2b8a7dc1d636.zip
ppc: Fix emulated INFINITY and NAN conversions
helper_todouble() was not properly converting INFINITY from 32 bit float to 64 bit double. (Normalized operand conversion is unchanged, other than indentation.) Signed-off-by: Paul A. Clarke <pc@us.ibm.com> Message-Id: <1566242388-9244-1-git-send-email-pc@us.ibm.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'target')
-rw-r--r--target/ppc/fpu_helper.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/target/ppc/fpu_helper.c b/target/ppc/fpu_helper.c
index 23b9c97439..52bcda27a6 100644
--- a/target/ppc/fpu_helper.c
+++ b/target/ppc/fpu_helper.c
@@ -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;