From patchwork Wed Feb 6 17:05:25 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petar Jovanovic X-Patchwork-Id: 218695 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id D4D402C02C5 for ; Thu, 7 Feb 2013 04:06:58 +1100 (EST) Received: from localhost ([::1]:53730 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U38SW-0007qp-Py for incoming@patchwork.ozlabs.org; Wed, 06 Feb 2013 12:06:56 -0500 Received: from eggs.gnu.org ([208.118.235.92]:48787) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U38SM-0007qQ-0e for qemu-devel@nongnu.org; Wed, 06 Feb 2013 12:06:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U38SK-0003CL-Aw for qemu-devel@nongnu.org; Wed, 06 Feb 2013 12:06:45 -0500 Received: from mail.rt-rk.ftn.uns.ac.rs ([147.91.177.140]:42695 helo=mail.rt-rk.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U38SK-0003Bl-52 for qemu-devel@nongnu.org; Wed, 06 Feb 2013 12:06:44 -0500 Received: from mail.rt-rk.com (mail.localdomain [127.0.0.1]) by mail.rt-rk.com (Postfix) with SMTP id 3AE1325BADE for ; Wed, 6 Feb 2013 18:06:40 +0100 (CET) X-Virus-Scanned: amavisd-new at rt-rk.com From: Petar Jovanovic To: qemu-devel@nongnu.org Date: Wed, 6 Feb 2013 18:05:25 +0100 Message-Id: <1360170325-3218-1-git-send-email-petar.jovanovic@rt-rk.com> X-Mailer: git-send-email 1.7.9.5 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 147.91.177.140 Cc: petarj@mips.com, aurelien@aurel32.net Subject: [Qemu-devel] [PATCH] target-mips: fix for incorrect multiplication with MULQ_S.PH X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Petar Jovanovic The change corrects sign-related issue with MULQ_S.PH. It also includes extension to the already existing test which will trigger the issue. Signed-off-by: Petar Jovanovic --- target-mips/dsp_helper.c | 2 +- tests/tcg/mips/mips32-dspr2/mulq_s_ph.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/target-mips/dsp_helper.c b/target-mips/dsp_helper.c index 96cb044..6781da8 100644 --- a/target-mips/dsp_helper.c +++ b/target-mips/dsp_helper.c @@ -652,7 +652,7 @@ static inline int32_t mipsdsp_sat16_mul_q15_q15(uint16_t a, uint16_t b, temp = 0x7FFF0000; set_DSPControl_overflow_flag(1, 21, env); } else { - temp = ((uint32_t)a * (uint32_t)b); + temp = (int16_t)a * (int16_t)b; temp = temp << 1; } diff --git a/tests/tcg/mips/mips32-dspr2/mulq_s_ph.c b/tests/tcg/mips/mips32-dspr2/mulq_s_ph.c index d0f7674..00e0155 100644 --- a/tests/tcg/mips/mips32-dspr2/mulq_s_ph.c +++ b/tests/tcg/mips/mips32-dspr2/mulq_s_ph.c @@ -6,6 +6,21 @@ int main() int rd, rs, rt, dsp; int result, resultdsp; + rs = 0x80000000; + rt = 0x0ffc0000; + result = 0xF0040000; + resultdsp = 0; + + __asm + ("mulq_s.ph %0, %2, %3\n\t" + "rddsp %1\n\t" + : "=r"(rd), "=r"(dsp) + : "r"(rs), "r"(rt) + ); + dsp = (dsp >> 21) & 0x01; + assert(rd == result); + assert(dsp == resultdsp); + rs = 0x80001234; rt = 0x80004321; result = 0x7FFF098B;