From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N1fap-0008JA-Ao for qemu-devel@nongnu.org; Sat, 24 Oct 2009 08:19:35 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N1fah-0008E3-L0 for qemu-devel@nongnu.org; Sat, 24 Oct 2009 08:19:32 -0400 Received: from [199.232.76.173] (port=58456 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N1fag-0008Do-NG for qemu-devel@nongnu.org; Sat, 24 Oct 2009 08:19:26 -0400 Received: from smtp.nokia.com ([192.100.105.134]:50583 helo=mgw-mx09.nokia.com) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1N1fag-0004Ie-7c for qemu-devel@nongnu.org; Sat, 24 Oct 2009 08:19:26 -0400 Received: from vaebh106.NOE.Nokia.com (vaebh106.europe.nokia.com [10.160.244.32]) by mgw-mx09.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id n9OCJNJe008948 for ; Sat, 24 Oct 2009 07:19:24 -0500 Received: from localhost.localdomain (essapo-nirac252105.europe.nokia.com [10.162.252.105]) by mgw-sa02.ext.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id n9OCJ8qG022164 for ; Sat, 24 Oct 2009 15:19:21 +0300 From: juha.riihimaki@nokia.com Date: Sat, 24 Oct 2009 15:19:09 +0300 Message-Id: <1256386749-85299-11-git-send-email-juha.riihimaki@nokia.com> In-Reply-To: <1256386749-85299-1-git-send-email-juha.riihimaki@nokia.com> References: <1256386749-85299-1-git-send-email-juha.riihimaki@nokia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH v2 10/10] target-arm: fix neon shift helper functions List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org From: Juha Riihim=C3=A4ki Current code is broken at least on gcc 4.2, the result of a comparison "-1 >=3D sizeof(type) * 8" results true and causes wrong code path to be taken. The fix has been revised to use a type cast instead of abs() function and extra checks. Signed-off-by: Juha Riihim=C3=A4ki --- target-arm/neon_helper.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) diff --git a/target-arm/neon_helper.c b/target-arm/neon_helper.c index f32ecd6..440b2ec 100644 --- a/target-arm/neon_helper.c +++ b/target-arm/neon_helper.c @@ -392,7 +392,7 @@ NEON_VOP(abd_u32, neon_u32, 1) #define NEON_FN(dest, src1, src2) do { \ int8_t tmp; \ tmp =3D (int8_t)src2; \ - if (tmp >=3D sizeof(src1) * 8 || tmp <=3D -sizeof(src1) * 8) { \ + if (tmp >=3D (int)sizeof(src1) * 8 || tmp <=3D -sizeof(src1) * 8) { = \ dest =3D 0; \ } else if (tmp < 0) { \ dest =3D src1 >> -tmp; \ @@ -420,7 +420,7 @@ uint64_t HELPER(neon_shl_u64)(uint64_t val, uint64_t = shiftop) #define NEON_FN(dest, src1, src2) do { \ int8_t tmp; \ tmp =3D (int8_t)src2; \ - if (tmp >=3D sizeof(src1) * 8) { \ + if (tmp >=3D (int)sizeof(src1) * 8) { \ dest =3D 0; \ } else if (tmp <=3D -sizeof(src1) * 8) { \ dest =3D src1 >> (sizeof(src1) * 8 - 1); \ @@ -453,7 +453,7 @@ uint64_t HELPER(neon_shl_s64)(uint64_t valop, uint64_= t shiftop) #define NEON_FN(dest, src1, src2) do { \ int8_t tmp; \ tmp =3D (int8_t)src2; \ - if (tmp >=3D sizeof(src1) * 8) { \ + if (tmp >=3D (int)sizeof(src1) * 8) { \ dest =3D 0; \ } else if (tmp < -sizeof(src1) * 8) { \ dest =3D src1 >> (sizeof(src1) * 8 - 1); \ @@ -494,7 +494,7 @@ uint64_t HELPER(neon_rshl_s64)(uint64_t valop, uint64= _t shiftop) #define NEON_FN(dest, src1, src2) do { \ int8_t tmp; \ tmp =3D (int8_t)src2; \ - if (tmp >=3D sizeof(src1) * 8 || tmp < -sizeof(src1) * 8) { \ + if (tmp >=3D (int)sizeof(src1) * 8 || tmp < -sizeof(src1) * 8) { \ dest =3D 0; \ } else if (tmp =3D=3D -sizeof(src1) * 8) { \ dest =3D src1 >> (tmp - 1); \ @@ -528,7 +528,7 @@ uint64_t HELPER(neon_rshl_u64)(uint64_t val, uint64_t= shiftop) #define NEON_FN(dest, src1, src2) do { \ int8_t tmp; \ tmp =3D (int8_t)src2; \ - if (tmp >=3D sizeof(src1) * 8) { \ + if (tmp >=3D (int)sizeof(src1) * 8) { \ if (src1) { \ SET_QC(); \ dest =3D ~0; \ @@ -579,7 +579,7 @@ uint64_t HELPER(neon_qshl_u64)(CPUState *env, uint64_= t val, uint64_t shiftop) #define NEON_FN(dest, src1, src2) do { \ int8_t tmp; \ tmp =3D (int8_t)src2; \ - if (tmp >=3D sizeof(src1) * 8) { \ + if (tmp >=3D (int)sizeof(src1) * 8) { \ if (src1) \ SET_QC(); \ dest =3D src1 >> 31; \ --=20 1.6.5