From patchwork Tue Sep 3 15:36:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 172810 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp16901ily; Tue, 3 Sep 2019 08:39:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqy70UfRzERgDiVucFrgl08FL5Rh5MHRJcU8a9YTXWWrvk/iaJO14WDnjpDEiLOH0Ie3xL/8 X-Received: by 2002:ac8:67c7:: with SMTP id r7mr34352666qtp.372.1567525185287; Tue, 03 Sep 2019 08:39:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567525185; cv=none; d=google.com; s=arc-20160816; b=iEGhFbqUtfRtwtBB1bafdm4BOUBUme9Uke/wD6AkPerkvOfHe+guPuwsgTVvxkpDZv 7MlUFAYmJwnxEq60GZp+iCVCOxi4m7YRJXNs5gjBSr/bE3M81Vz2ZrA9AZt1E4hky/U8 z5HYvedX1F1BsrBFJN6brCMRX493Yzbp2AXSnwkZbxF533umCl4LQO8Pk/pdpOxxfA0+ YvPi7+kQCC769i8Ne/RqvIaUB+bsaaKOD++168fB5/bXwF5Gg1/6NxafiCN6NNIltaQO RkcKHqFdjfEcLpnt8Zq8pUOnswww50O9wNHIv5vU7m5fqdgIOLexVV5Loot/7cJqeuCB 0bgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=NjtHLR890FdwVKLAyT2SN75yV6fIIwqW8EkRht8FO+8=; b=pehflqHcE8zwOYjE/Z7TCNimYykbYsWuZQGNVr7Hn1YnMF0tR5cwHqzjqcbBPP2yeu 83o9JEocNI6eL5mnSrXSb4hl9Z2WKNI2davUAMVGoh6qJAPslvBBjehzAMY7UoLySJBZ IYPa8P0K1VY9ZWkVi1Huc4Oyr6Y6QcJ3a8b67aiN83FOFZi+quDa3LXIJJjwYY7lmvco 5SlLRPf/+V7HNuwEvp9uZUgi8P+XYCXx41AuLAS9jWeAazzKMOln+bmVAAiz/kpkLCNh qzIJP4S+mcsF8sKlj8TNroXSVvRyCSxPW8IBY4QgUq9FMFypSM3obS6zoQGrtzFoD2Fn g90g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Zkenw7tN; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id l21si11602417qtb.247.2019.09.03.08.39.45 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Sep 2019 08:39:45 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Zkenw7tN; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47666 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5AuG-0004HW-7m for patch@linaro.org; Tue, 03 Sep 2019 11:39:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59228) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5ArR-0002pv-3X for qemu-devel@nongnu.org; Tue, 03 Sep 2019 11:36:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5ArP-0005x7-Tp for qemu-devel@nongnu.org; Tue, 03 Sep 2019 11:36:48 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]:44856) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i5ArP-0005wa-NC for qemu-devel@nongnu.org; Tue, 03 Sep 2019 11:36:47 -0400 Received: by mail-wr1-x429.google.com with SMTP id 30so7041727wrk.11 for ; Tue, 03 Sep 2019 08:36:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=NjtHLR890FdwVKLAyT2SN75yV6fIIwqW8EkRht8FO+8=; b=Zkenw7tNFlOyNSkp/8WXRNoHFBds3lE5LyDaCVMd6npQSpLsd3o9s9jpezofycxckc Wj3C0pebOoZn8zSnl7+fFpOuM2nc3bB/yqG1zsAP1U4DyrVKopmJG1oouphdNSNwbaFW 4hvDUvzIeXLKuvYds7EXep+nmrlanzREhcDbc6ESEVVeCW3Rke3IoCNn6gcJ0pne93fh RoPA7GMiHcC593stot8qLwt1XGi1BXK8xxJOohF3vWzmnW3/z3DmHMa0gw7nrC66qlbb gUBS/tNp9PL0Snrt2WhGuusvyF5cuV52DhTXjaqZX00Mj8jAbS2S/QG5h+pxSowxcMR6 iojg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NjtHLR890FdwVKLAyT2SN75yV6fIIwqW8EkRht8FO+8=; b=YpCpFhCfHPurJvz5iV+24NOKE0ExS3HaNAQXIelL/fz8h/t94c/d8aH6AuWesKtlpI nuWYDplSlgFyolOxbkLwLvjNs2MC4hltULL/aj4A2/kuedq1wPj3T9jyljulHyvROvqB imS7yE0vnWuCgozkGST8TQxexGjX2yf1T3wmpr22sB4CNGJW29akb1kPhzvz29uP3TqJ tCDA863X2GQ4xHAIpXxE5SJGsUYC7G5KLF6TGEjMAO45EC+952wtSd0rGbinA18udCH/ IrGxQhGUUNjZQfWfGnAA7IStMxTC2fl7MbgNg23gFAFfZvBXHJbClFrb+dJZq7k3q5Ef hvoQ== X-Gm-Message-State: APjAAAXE3OnzAdb1Hyj3S8b5yj1hrGfmwp3231tHryK6zDAa6zbHkju5 9zmVUhlyphfKZ6yMEo+t+sap4zkNseRWqA== X-Received: by 2002:adf:f00b:: with SMTP id j11mr27073913wro.298.1567525006490; Tue, 03 Sep 2019 08:36:46 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id a18sm24435188wrt.18.2019.09.03.08.36.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2019 08:36:46 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Tue, 3 Sep 2019 16:36:21 +0100 Message-Id: <20190903153633.6651-10-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190903153633.6651-1-peter.maydell@linaro.org> References: <20190903153633.6651-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::429 Subject: [Qemu-devel] [PULL 09/21] target/arm: Fix SMMLS argument order X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson The previous simplification got the order of operands to the subtraction wrong. Since the 64-bit product is the subtrahend, we must use a 64-bit subtract to properly compute the borrow from the low-part of the product. Fixes: 5f8cd06ebcf5 ("target/arm: Simplify SMMLA, SMMLAR, SMMLS, SMMLSR") Reported-by: Laurent Desnogues Signed-off-by: Richard Henderson Tested-by: Laurent Desnogues Message-id: 20190829013258.16102-1-richard.henderson@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/translate.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) -- 2.20.1 diff --git a/target/arm/translate.c b/target/arm/translate.c index 78d93f63cab..cfebd35d268 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -8831,7 +8831,16 @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) if (rd != 15) { tmp3 = load_reg(s, rd); if (insn & (1 << 6)) { - tcg_gen_sub_i32(tmp, tmp, tmp3); + /* + * For SMMLS, we need a 64-bit subtract. + * Borrow caused by a non-zero multiplicand + * lowpart, and the correct result lowpart + * for rounding. + */ + TCGv_i32 zero = tcg_const_i32(0); + tcg_gen_sub2_i32(tmp2, tmp, zero, tmp3, + tmp2, tmp); + tcg_temp_free_i32(zero); } else { tcg_gen_add_i32(tmp, tmp, tmp3); } @@ -10075,7 +10084,14 @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) if (insn & (1 << 20)) { tcg_gen_add_i32(tmp, tmp, tmp3); } else { - tcg_gen_sub_i32(tmp, tmp, tmp3); + /* + * For SMMLS, we need a 64-bit subtract. + * Borrow caused by a non-zero multiplicand lowpart, + * and the correct result lowpart for rounding. + */ + TCGv_i32 zero = tcg_const_i32(0); + tcg_gen_sub2_i32(tmp2, tmp, zero, tmp3, tmp2, tmp); + tcg_temp_free_i32(zero); } tcg_temp_free_i32(tmp3); }