Patchwork [05/10] target-arm: Fix saturated values for Neon right shifts

login
register
mail settings
Submitter Peter Maydell
Date Feb. 15, 2011, 1:44 p.m.
Message ID <1297777490-5323-6-git-send-email-peter.maydell@linaro.org>
Download mbox | patch
Permalink /patch/83249/
State New
Headers show

Comments

Peter Maydell - Feb. 15, 2011, 1:44 p.m.
Fix value returned by signed 8 and 16 bit qrshl helpers
when the result has saturated.

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

Patch

diff --git a/target-arm/neon_helper.c b/target-arm/neon_helper.c
index a8885fa..7859f0b 100644
--- a/target-arm/neon_helper.c
+++ b/target-arm/neon_helper.c
@@ -886,7 +886,10 @@  uint64_t HELPER(neon_qrshl_u64)(CPUState *env, uint64_t val, uint64_t shiftop)
         dest = src1 << tmp; \
         if ((dest >> tmp) != src1) { \
             SET_QC(); \
-            dest = src1 >> 31; \
+            dest = (uint32_t)(1 << (sizeof(src1) * 8 - 1)); \
+            if (src1 > 0) { \
+                dest--; \
+            } \
         } \
     }} while (0)
 NEON_VOP_ENV(qrshl_s8, neon_s8, 4)