From patchwork Wed Oct 21 11:01:11 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: 36530 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 DDB58B7B95 for ; Wed, 21 Oct 2009 23:06:26 +1100 (EST) Received: from localhost ([127.0.0.1]:54880 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N0ZxP-0008CK-Ra for incoming@patchwork.ozlabs.org; Wed, 21 Oct 2009 08:06:23 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N0Ywi-0001jF-TN for qemu-devel@nongnu.org; Wed, 21 Oct 2009 07:01:36 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N0Ywd-0001eM-8x for qemu-devel@nongnu.org; Wed, 21 Oct 2009 07:01:35 -0400 Received: from [199.232.76.173] (port=55633 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N0Ywd-0001e6-22 for qemu-devel@nongnu.org; Wed, 21 Oct 2009 07:01:31 -0400 Received: from smtp.nokia.com ([192.100.122.233]:31120 helo=mgw-mx06.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 1N0Ywc-0006pY-31 for qemu-devel@nongnu.org; Wed, 21 Oct 2009 07:01:30 -0400 Received: from vaebh106.NOE.Nokia.com (vaebh106.europe.nokia.com [10.160.244.32]) by mgw-mx06.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id n9LB1JXP017216 for ; Wed, 21 Oct 2009 14:01:24 +0300 Received: from vaebh102.NOE.Nokia.com ([10.160.244.23]) by vaebh106.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 21 Oct 2009 14:01:02 +0300 Received: from smtp.mgd.nokia.com ([65.54.30.8]) by vaebh102.NOE.Nokia.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Wed, 21 Oct 2009 14:00:58 +0300 Received: from NOK-EUMSG-05.mgdnok.nokia.com ([65.54.30.90]) by nok-am1mhub-04.mgdnok.nokia.com ([65.54.30.8]) with mapi; Wed, 21 Oct 2009 13:00:56 +0200 From: To: Date: Wed, 21 Oct 2009 13:01:11 +0200 Thread-Topic: [PATCH 12/12] [RESEND] target-arm: fix neon shift helper functions Thread-Index: AcpSPcQDjWm/5udPR6+KFlJ4mr9xCQ== Message-ID: <3B23632B-8EC3-4CED-9E73-C1EC7142C9C3@nokia.com> Accept-Language: en, en-US Content-Language: en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: acceptlanguage: en, en-US MIME-Version: 1.0 X-OriginalArrivalTime: 21 Oct 2009 11:00:58.0062 (UTC) FILETIME=[C4BC06E0:01CA523D] X-Nokia-AV: Clean X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 1) Subject: [Qemu-devel] [PATCH 12/12] [RESEND] 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 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 utilizes abs() function where applicable and otherwise adds a test to ensure both arguments are positive before making the aforementioned comparison. Signed-off-by: Juha Riihimäki --- 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 >= 0 && tmp >= 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 (abs(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 >= 0 && tmp >= 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 >= 0 && tmp >= sizeof(src1) * 8) { \ if (src1) \ SET_QC(); \ dest = src1 >> 31; \ diff --git a/target-arm/neon_helper.c b/target-arm/neon_helper.c index f32ecd6..0c95035 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 (abs(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 >= 0 && tmp >= sizeof(src1) * 8) { \ dest = 0; \ } else if (tmp <= -sizeof(src1) * 8) { \