From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LRs2K-0001Jt-OP for qemu-devel@nongnu.org; Tue, 27 Jan 2009 12:47:45 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LRs2J-0001JA-3Z for qemu-devel@nongnu.org; Tue, 27 Jan 2009 12:47:43 -0500 Received: from [199.232.76.173] (port=36668 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LRs2I-0001Io-6S for qemu-devel@nongnu.org; Tue, 27 Jan 2009 12:47:42 -0500 Received: from mx20.gnu.org ([199.232.41.8]:35172) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LRs2H-0002SA-OA for qemu-devel@nongnu.org; Tue, 27 Jan 2009 12:47:41 -0500 Received: from mail.codesourcery.com ([65.74.133.4]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LRs2G-0001Jl-0E for qemu-devel@nongnu.org; Tue, 27 Jan 2009 12:47:40 -0500 Date: Tue, 27 Jan 2009 17:47:32 +0000 From: Julian Brown Message-ID: <20090127174732.27db1f88@rex.config> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="MP_/E2UbaNS2ENXafBIuPrrKlXt" Subject: [Qemu-devel] Fix -sizeof(foo) in target-arm/neon_helper.c shift helpers Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: paul@codesourcery.com --MP_/E2UbaNS2ENXafBIuPrrKlXt Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline This patch fixes some bogus comparisons in the helpers for ARM NEON shift operations, which negate sizeof(foo) without taking into account that the result of that expression is unsigned. I have no qemu write access, so can someone apply this for me if OK? Thanks, Julian ChangeLog * target-arm/neon_helper.c (shl_u8, shl_u16, shl_u32): Fix greater-than-element-size boundary condition. (shl_s8, shl_s16, shl_s32): Likewise. (rshl_s8, rshl_s16, rshl_s32, rshl_u8, rshl_u16, rshl_u32) (qshl_s8, qshl_s16, qshl_s32, qshl_u8, qshl_u16, qshl_u32): Add casts to uses of -sizeof(), fix boundary conditions. --MP_/E2UbaNS2ENXafBIuPrrKlXt Content-Type: text/x-patch; name=neon-minus-sizeof-fixes-2.diff Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=neon-minus-sizeof-fixes-2.diff Index: target-arm/neon_helper.c =================================================================== --- target-arm/neon_helper.c (revision 222269) +++ target-arm/neon_helper.c (working copy) @@ -392,7 +392,7 @@ NEON_VOP(abd_u32, neon_u32, 1) #define NEON_FN(dest, src1, src2) do { \ int8_t tmp; \ tmp = (int8_t)src2; \ - if (tmp >= sizeof(src1) * 8 || tmp <= -sizeof(src1) * 8) { \ + if (abs(tmp) >= sizeof(src1) * 8) { \ dest = 0; \ } else if (tmp < 0) { \ dest = src1 >> -tmp; \ @@ -422,7 +422,7 @@ uint64_t HELPER(neon_shl_u64)(uint64_t v tmp = (int8_t)src2; \ if (tmp >= sizeof(src1) * 8) { \ dest = 0; \ - } else if (tmp <= -sizeof(src1) * 8) { \ + } else if (tmp <= -(int) (sizeof(src1) * 8)) { \ dest = src1 >> (sizeof(src1) * 8 - 1); \ } else if (tmp < 0) { \ dest = src1 >> -tmp; \ @@ -455,9 +455,9 @@ uint64_t HELPER(neon_shl_s64)(uint64_t v tmp = (int8_t)src2; \ if (tmp >= sizeof(src1) * 8) { \ dest = 0; \ - } else if (tmp < -sizeof(src1) * 8) { \ + } else if (tmp < -(int) (sizeof(src1) * 8)) { \ dest >>= sizeof(src1) * 8 - 1; \ - } else if (tmp == -sizeof(src1) * 8) { \ + } else if (tmp == -(int) (sizeof(src1) * 8)) { \ dest = src1 >> (tmp - 1); \ dest++; \ src2 >>= 1; \ @@ -494,9 +494,9 @@ uint64_t HELPER(neon_rshl_s64)(uint64_t #define NEON_FN(dest, src1, src2) do { \ int8_t tmp; \ tmp = (int8_t)src2; \ - if (tmp >= sizeof(src1) * 8 || tmp < -sizeof(src1) * 8) { \ + if (abs(tmp) >= sizeof(src1) * 8) { \ dest = 0; \ - } else if (tmp == -sizeof(src1) * 8) { \ + } else if (tmp == -(int) (sizeof(src1) * 8)) { \ dest = src1 >> (tmp - 1); \ } else if (tmp < 0) { \ dest = (src1 + (1 << (-1 - tmp))) >> -tmp; \ @@ -535,7 +535,7 @@ uint64_t HELPER(neon_rshl_u64)(uint64_t } else { \ dest = 0; \ } \ - } else if (tmp <= -sizeof(src1) * 8) { \ + } else if (tmp <= -(int) (sizeof(src1) * 8)) { \ dest = 0; \ } else if (tmp < 0) { \ dest = src1 >> -tmp; \ @@ -583,7 +583,7 @@ uint64_t HELPER(neon_qshl_u64)(CPUState if (src1) \ SET_QC(); \ dest = src1 >> 31; \ - } else if (tmp <= -sizeof(src1) * 8) { \ + } else if (tmp <= -(int) (sizeof(src1) * 8)) { \ dest = src1 >> 31; \ } else if (tmp < 0) { \ dest = src1 >> -tmp; \ --MP_/E2UbaNS2ENXafBIuPrrKlXt--