Patchwork [2/2] target-arm: Fix 32 bit signed saturating narrow

login
register
mail settings
Submitter Peter Maydell
Date Feb. 9, 2011, 3:42 p.m.
Message ID <1297266153-5526-3-git-send-email-peter.maydell@linaro.org>
Download mbox | patch
Permalink /patch/82493/
State New
Headers show

Comments

Peter Maydell - Feb. 9, 2011, 3:42 p.m.
The returned value when doing saturating signed 64->32 bit
conversion of a negative number was incorrect due to a missing cast.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 target-arm/neon_helper.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Patch

diff --git a/target-arm/neon_helper.c b/target-arm/neon_helper.c
index a7cf383..61890dd 100644
--- a/target-arm/neon_helper.c
+++ b/target-arm/neon_helper.c
@@ -1209,7 +1209,7 @@  uint32_t HELPER(neon_narrow_sat_s32)(CPUState *env, uint64_t x)
 {
     if ((int64_t)x != (int32_t)x) {
         SET_QC();
-        return (x >> 63) ^ 0x7fffffff;
+        return ((int64_t)x >> 63) ^ 0x7fffffff;
     }
     return x;
 }