From patchwork Sat Oct 24 12:19:09 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Juha.Riihimaki@nokia.com X-Patchwork-Id: 36838 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 52F7BB7BCF for ; Sat, 24 Oct 2009 23:40:04 +1100 (EST) Received: from localhost ([127.0.0.1]:50800 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N1fub-0001BV-8h for incoming@patchwork.ozlabs.org; Sat, 24 Oct 2009 08:40:01 -0400 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 vaebh104.NOE.Nokia.com ([10.160.244.30]) by vaebh106.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Sat, 24 Oct 2009 15:19:22 +0300 Received: from mgw-sa02.ext.nokia.com ([147.243.1.48]) by vaebh104.NOE.Nokia.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Sat, 24 Oct 2009 15:19:22 +0300 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 To: qemu-devel@nongnu.org Date: Sat, 24 Oct 2009 15:19:09 +0300 Message-Id: <1256386749-85299-11-git-send-email-juha.riihimaki@nokia.com> X-Mailer: git-send-email 1.6.5 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 X-OriginalArrivalTime: 24 Oct 2009 12:19:22.0734 (UTC) FILETIME=[382D40E0:01CA54A4] X-Nokia-AV: Clean X-MIME-Autoconverted: from 8bit to quoted-printable by mgw-mx09.nokia.com id n9OCJNJe008948 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 1) Subject: [Qemu-devel] [PATCH v2 10/10] target-arm: fix neon shift helper functions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Juha Riihimäki Current code is broken at least on gcc 4.2, the result of a comparison "-1 >= 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äki --- 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 = (int8_t)src2; \ - if (tmp >= sizeof(src1) * 8 || tmp <= -sizeof(src1) * 8) { \ + if (tmp >= (int)sizeof(src1) * 8 || tmp <= -sizeof(src1) * 8) { \ dest = 0; \ } else if (tmp < 0) { \ dest = 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 = (int8_t)src2; \ - if (tmp >= sizeof(src1) * 8) { \ + if (tmp >= (int)sizeof(src1) * 8) { \ dest = 0; \ } else if (tmp <= -sizeof(src1) * 8) { \ dest = 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 = (int8_t)src2; \ - if (tmp >= sizeof(src1) * 8) { \ + if (tmp >= (int)sizeof(src1) * 8) { \ dest = 0; \ } else if (tmp < -sizeof(src1) * 8) { \ dest = 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 = (int8_t)src2; \ - if (tmp >= sizeof(src1) * 8 || tmp < -sizeof(src1) * 8) { \ + if (tmp >= (int)sizeof(src1) * 8 || tmp < -sizeof(src1) * 8) { \ dest = 0; \ } else if (tmp == -sizeof(src1) * 8) { \ dest = 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 = (int8_t)src2; \ - if (tmp >= sizeof(src1) * 8) { \ + if (tmp >= (int)sizeof(src1) * 8) { \ if (src1) { \ SET_QC(); \ dest = ~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 = (int8_t)src2; \ - if (tmp >= sizeof(src1) * 8) { \ + if (tmp >= (int)sizeof(src1) * 8) { \ if (src1) \ SET_QC(); \ dest = src1 >> 31; \