From patchwork Thu Aug 29 01:32:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 172513 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp1538073ily; Wed, 28 Aug 2019 18:34:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqz5spSerUIqOY7lcRaulll5IJiFGPuiZgUq0YehrDmVdm6LIkTmPxO5kv34FebpsxgQ0pLz X-Received: by 2002:a17:906:a89a:: with SMTP id ha26mr5892175ejb.110.1567042485201; Wed, 28 Aug 2019 18:34:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567042485; cv=none; d=google.com; s=arc-20160816; b=XB3tFO1rT9KYrFLi+kYOpDnDInjuy4UIg8JE5XFrexY2SnQuMtX/ONItV2N24nGWCR bymwcJsgbCz8nbBfGN4Gk8rRXPI3+sur8H88nKgcimYNQ7TY9gxo57VAIbEWlgQO71ff 2a6oh7ueHF/LLJ7ctCE315a5r1b+V2CpRyaTooLQtFMM8/o7semduoHvM1QON81TBD7V GT7CdQWqE98ucuw54anqb63wUmntS8sIoD6OpwxJVnQjDoz3/BWUjsrQiWVQiIJey099 XiC1J0t1Pii0hTuBz0qyw9HUUlKVfkUqUnRObHGJn8+FFdb4ryQAeklfsshbKl/gBVm+ sbSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:message-id:date:to:from :dkim-signature; bh=744Nlg5qsnK3Xn9iAOjHRV5LS028FvH66MjBiNi4Lvg=; b=p3qo1FPnJd8lDGvh9z2IspAzHk8yzPzKB81CFiUlOEeC1F9ysAEjsnnmNSh+Wzxuyr S/y0iK5z6nI3fGzhjS5T9fVt/1ZlIxRyA6Qqpik5lS99oxGTata0aRljVxXKO0TIhxUF BymkPEYYpI1YaiPVmWKBqczsd5QMg4GRmMiPzDi0chS3RDVrXospOB3EKr0VKBlmN7H3 uQFl1avVAh3XsEK5NnhlS6d3P64VMaILNv0nSJefx24jcibC6lQi4cRjh+shXNqOhfZz cCXY7OHo8YYuxDHqQBRIoLleDw8z0urtCF12xXWe47DXdx0SETlaoDvDyY0w1C5NumPU wTLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=j6ZyTcAa; 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 k40si402389edb.14.2019.08.28.18.34.45 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 28 Aug 2019 18:34: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=j6ZyTcAa; 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]:44350 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i39Km-0007dw-6e for patch@linaro.org; Wed, 28 Aug 2019 21:34:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48791) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i39J9-0006oS-SK for qemu-devel@nongnu.org; Wed, 28 Aug 2019 21:33:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i39J8-0006Tu-Dm for qemu-devel@nongnu.org; Wed, 28 Aug 2019 21:33:03 -0400 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:33084) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i39J8-0006TV-7W for qemu-devel@nongnu.org; Wed, 28 Aug 2019 21:33:02 -0400 Received: by mail-pg1-x544.google.com with SMTP id n190so689552pgn.0 for ; Wed, 28 Aug 2019 18:33:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=744Nlg5qsnK3Xn9iAOjHRV5LS028FvH66MjBiNi4Lvg=; b=j6ZyTcAaZKSBehcYvEOFfr3Q4xcRN8Cx9lnoetgVmd4YqOXv1nv+y2q2qV1hDy8tl5 dyk10HCINJRzErY5iZUPybsDjlywwJI9P5p9EmjnjnHw5NASI+LsNE9qTh7PiYt+xq7h 9iX6vTwBd+l4ogL3HqOgYNjAa06tH1Jy9v9SUtmRpfqrpOYK5OEIpo2XW3AZ5t9P5Zl9 NV80Do3OrZuy8P455Gh1+3qGY2b2O/OVATeIJR616/4cvw/Uqa2LHVJUBZevPCXdMyeS PX+TIVGuGzQNEZWHV/6u3JsEVzldTfehD/6hS2+anCUFw8E21imG1bw0XHxK7kFsUu+I Odww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=744Nlg5qsnK3Xn9iAOjHRV5LS028FvH66MjBiNi4Lvg=; b=JrbOqPhaVGrjnUnsiFm46OMagxjghCN60WtLUORrdy6s1CoKIeGZKsMkWhQrbFH7kk NzaCgP3NLH1kLEk3CoTkvOm4SKiKPJC9T8/7wrlGm8Fu3AxHkDp2Qr0plYydvocsE+Zb njYx6Mtg7rsziagG/MDLgNHhfBpDiTkO4k/nx/re8Ggpl4BUsjeMPS5gpzT5ux+1HKOd qYSlqfY2G8MDQulCWFFsOEUt9b0JVzJ5w8CIHtyHTVhToZyvJY1wC7UKm/WnA7WaIexR P1jZni9p1NZ53SG6NLFrKCX/vJQr+DGc+iNRV4qV0DO+buwriwQ8HUtxNEhkBeTKCcxy TOfg== X-Gm-Message-State: APjAAAWQSQIPYLXuGufEZF3p9fofteOZOH7dKrw9C56GvxzYZsvAulDs tONR5QvsKgp0WWtwtsY/FPxzPy6UtDo= X-Received: by 2002:a63:eb56:: with SMTP id b22mr6091093pgk.355.1567042380367; Wed, 28 Aug 2019 18:33:00 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id h17sm701303pfo.24.2019.08.28.18.32.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Aug 2019 18:32:59 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 28 Aug 2019 18:32:58 -0700 Message-Id: <20190829013258.16102-1-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::544 Subject: [Qemu-devel] [PATCH] 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: , Cc: laurent.desnogues@gmail.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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 --- target/arm/translate.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) -- 2.17.1 Tested-by: Laurent Desnogues diff --git a/target/arm/translate.c b/target/arm/translate.c index cbe19b7a62..a0f7577f47 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -8824,7 +8824,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); } @@ -10068,7 +10077,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); }