From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=54066 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PnueY-0008Ry-Hd for qemu-devel@nongnu.org; Fri, 11 Feb 2011 10:11:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PnueR-0003dB-KF for qemu-devel@nongnu.org; Fri, 11 Feb 2011 10:11:22 -0500 Received: from eu1sys200aog102.obsmtp.com ([207.126.144.113]:37479) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PnueR-0003cm-6s for qemu-devel@nongnu.org; Fri, 11 Feb 2011 10:11:15 -0500 Received: from zeta.dmz-eu.st.com (ns2.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 49970173 for ; Fri, 11 Feb 2011 15:11:14 +0000 (GMT) Received: from Webmail-eu.st.com (safex1hubcas5.st.com [10.75.90.71]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 34D9C4D11 for ; Fri, 11 Feb 2011 15:11:14 +0000 (GMT) From: Date: Fri, 11 Feb 2011 16:11:00 +0100 Message-ID: <1297437062-6118-5-git-send-email-christophe.lyon@st.com> In-Reply-To: <1297437062-6118-1-git-send-email-christophe.lyon@st.com> References: <1297437062-6118-1-git-send-email-christophe.lyon@st.com> MIME-Version: 1.0 Content-Type: text/plain Subject: [Qemu-devel] [PATCH 4/6] target-arm: fix saturated values for Neon right shifts. List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org 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; -- 1.7.2.3