diff mbox

[42/48] target-arm: fix signed narrow 64->32 operation

Message ID 7d5786fe88c6fb3555cb4c24846d7cfae97994ae.1269617187.git.riku.voipio@nokia.com
State New
Headers show

Commit Message

Riku Voipio March 26, 2010, 4:07 p.m. UTC
From: Juha Riihimäki <juha.riihimaki@nokia.com>

Signed-Off-By: Riku Voipio <riku.voipio@nokia.com>
Signed-off-by: Juha Riihimäki <juha.riihimaki@nokia.com>
---
 target-arm/neon_helper.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/target-arm/neon_helper.c b/target-arm/neon_helper.c
index 4604698..910f84a 100644
--- a/target-arm/neon_helper.c
+++ b/target-arm/neon_helper.c
@@ -1183,9 +1183,13 @@  uint32_t HELPER(neon_narrow_sat_u32)(CPUState *env, uint64_t x)
 
 uint32_t HELPER(neon_narrow_sat_s32)(CPUState *env, uint64_t x)
 {
-    if ((int64_t)x != (int32_t)x) {
+    if ((int64_t)x < -2147483648ll) {
         SET_QC();
-        return (x >> 63) ^ 0x7fffffff;
+        return 0x80000000;
+    }
+    if ((int64_t)x > 2147483647ll) {
+        SET_QC();
+        return 0x7fffffff;
     }
     return x;
 }