Patchwork [39/48] target-arm: fix neon vrshr instruction

login
register
mail settings
Submitter Riku Voipio
Date March 26, 2010, 4:06 p.m.
Message ID <f71510394f077c1440e4d128e1b9b1bd78ef3ae3.1269617187.git.riku.voipio@nokia.com>
Download mbox | patch
Permalink /patch/48678/
State New
Headers show

Comments

Riku Voipio - March 26, 2010, 4:06 p.m.
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, 7 insertions(+), 1 deletions(-)

Patch

diff --git a/target-arm/neon_helper.c b/target-arm/neon_helper.c
index 0df13f5..4604698 100644
--- a/target-arm/neon_helper.c
+++ b/target-arm/neon_helper.c
@@ -573,7 +573,13 @@  uint64_t HELPER(neon_rshl_u64)(uint64_t val, uint64_t shiftop)
         /* Rounding a 1-bit result just preserves that bit.  */
         val >>= 63;
     } if (shift < 0) {
-        val = (val + ((uint64_t)1 << (-1 - shift))) >> -shift;
+        uint64_t r = ((uint64_t)1 << (-1 - shift));
+        uint64_t lo = val + r;
+        if (lo < val || lo < r) {
+            val = (lo >> -shift) | ((1ull << 63) >> (-shift - 1));
+        } else {
+            val = lo >> -shift;
+        }
     } else {
         val <<= shift;
     }