From patchwork Thu Mar 10 18:51:49 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 86331 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 94D321007D4 for ; Fri, 11 Mar 2011 05:55:43 +1100 (EST) Received: from localhost ([127.0.0.1]:50172 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pxl1O-0002td-0d for incoming@patchwork.ozlabs.org; Thu, 10 Mar 2011 13:55:38 -0500 Received: from [140.186.70.92] (port=36241 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pxkxm-0001JT-DF for qemu-devel@nongnu.org; Thu, 10 Mar 2011 13:51:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pxkxk-0000ni-TY for qemu-devel@nongnu.org; Thu, 10 Mar 2011 13:51:54 -0500 Received: from mnementh.archaic.org.uk ([81.2.115.146]:48692) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pxkxk-0000nF-Mz for qemu-devel@nongnu.org; Thu, 10 Mar 2011 13:51:52 -0500 Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.72) (envelope-from ) id 1Pxkxh-0005Ce-Rx; Thu, 10 Mar 2011 18:51:49 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 10 Mar 2011 18:51:49 +0000 Message-Id: <1299783109-19977-1-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.3 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 81.2.115.146 Cc: patches@linaro.org Subject: [Qemu-devel] [PATCH] target-arm: Fix GE bits for v6media signed modulo arithmetic 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 Fix the signed modulo arithmetic helpers for the v6media instructions (SADD8, SSUB8, SADD16, SSUB16, SASX, SSAX) to set the GE bits correctly (based on the result of the add or subtract before it is truncated to 16 bits, not after). Signed-off-by: Peter Maydell --- target-arm/helper.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/target-arm/helper.c b/target-arm/helper.c index d360121..4f2b440 100644 --- a/target-arm/helper.c +++ b/target-arm/helper.c @@ -2171,7 +2171,7 @@ static inline uint8_t sub8_usat(uint8_t a, uint8_t b) /* Signed modulo arithmetic. */ #define SARITH16(a, b, n, op) do { \ int32_t sum; \ - sum = (int16_t)((uint16_t)(a) op (uint16_t)(b)); \ + sum = (int32_t)(int16_t)(a) op (int32_t)(int16_t)(b); \ RESULT(sum, n, 16); \ if (sum >= 0) \ ge |= 3 << (n * 2); \ @@ -2179,7 +2179,7 @@ static inline uint8_t sub8_usat(uint8_t a, uint8_t b) #define SARITH8(a, b, n, op) do { \ int32_t sum; \ - sum = (int8_t)((uint8_t)(a) op (uint8_t)(b)); \ + sum = (int32_t)(int8_t)(a) op (int32_t)(int8_t)(b); \ RESULT(sum, n, 8); \ if (sum >= 0) \ ge |= 1 << n; \