diff mbox

temporary-floating-point: Use "0 - val" for the negtive value

Message ID COL130-W54257B8D9619A1F99E1BB1B93C0@phx.gbl
State New
Headers show

Commit Message

Chen Gang Oct. 17, 2015, 1:46 p.m. UTC
From 5bfae9eaa7c6757c83b1b3d958dd24988394fb03 Mon Sep 17 00:00:00 2001
From: Chen Gang <gang.chen.5i5j@gmail.com>
Date: Sat, 17 Oct 2015 21:39:25 +0800
Subject: [PATCH] temporary-floating-point: Use "0 - val" for the negtive value

It is a bug, original implementation is incorrect.

Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
---
 target-tilegx/fpu_helper.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

-- 
1.9.3
diff mbox

Patch

diff --git a/target-tilegx/fpu_helper.c b/target-tilegx/fpu_helper.c
index 095085d..4aafda4 100644
--- a/target-tilegx/fpu_helper.c
+++ b/target-tilegx/fpu_helper.c
@@ -23,7 +23,6 @@ 
 #include "exec/helper-proto.h"
 #include "fpu/softfloat.h"
 
-#define SIGNBIT32 0x80000000
 #define FP_STATUS (fpu->fp_status)
 
 static void fdouble_ana(FPUTLGState *fpu,
@@ -129,8 +128,7 @@  uint64_t helper_fdouble_pack1(CPUTLGState *env,
     case 0x21b00:
         return float64_val(uint32_to_float64(rsrc>> 4, &FP_STATUS));
     case 0x121b00:
-        return float64_val(int32_to_float64((rsrc>> 4) | SIGNBIT32,
-                                            &FP_STATUS));
+        return float64_val(int32_to_float64(0 - (rsrc>> 4), &FP_STATUS));
     default:
         qemu_log_mask(LOG_UNIMP, "\nUIMP: in %s.\n", __FUNCTION__);
         helper_exception(env, TILEGX_EXCP_OPCODE_UNIMPLEMENTED);
@@ -217,7 +215,7 @@  uint64_t helper_fsingle_pack2(CPUTLGState *env, uint64_t rsrc)
     case 0x9e:
         return float32_val(uint32_to_float32(ctx.data, &FP_STATUS));
     case 0x49e:
-        return float32_val(int32_to_float32(ctx.data | SIGNBIT32, &FP_STATUS));
+        return float32_val(int32_to_float32(0 - ctx.data, &FP_STATUS));
     default:
         qemu_log_mask(LOG_UNIMP, "\nUIMP: in %s.\n", __FUNCTION__);
         helper_exception(env, TILEGX_EXCP_OPCODE_UNIMPLEMENTED);