From patchwork Fri Feb 11 15:11:00 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [4/6] target-arm: fix saturated values for Neon right shifts. From: Christophe LYON X-Patchwork-Id: 82804 Message-Id: <1297437062-6118-5-git-send-email-christophe.lyon@st.com> To: Date: Fri, 11 Feb 2011 16:11:00 +0100 From: Christophe Lyon Fix value returned by signed qrshl helpers (8, 16 and 32 bits). Signed-off-by: Christophe Lyon --- target-arm/neon_helper.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) diff --git a/target-arm/neon_helper.c b/target-arm/neon_helper.c index 907f7b7..83d610a 100644 --- a/target-arm/neon_helper.c +++ b/target-arm/neon_helper.c @@ -903,7 +903,7 @@ 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)) - (src1 > 0 ? 1 : 0); \ } \ }} while (0) NEON_VOP_ENV(qrshl_s8, neon_s8, 4) @@ -924,7 +924,11 @@ uint32_t HELPER(neon_qrshl_s32)(CPUState *env, uint32_t valop, uint32_t shiftop) dest = val << shift; if ((dest >> shift) != val) { SET_QC(); - dest = (uint32_t)(1 << (sizeof(val) * 8 - 1)) - (val > 0 ? 1 : 0); + if (val < 0) { + dest = INT32_MIN; + } else { + dest = INT32_MAX; + } } } return dest;