From patchwork Thu Aug 8 20:26:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 170837 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp9061724ile; Thu, 8 Aug 2019 13:29:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqzWqU0pEQHpZQKs3egdGywPem9Kwyxnl3H6Sd7s9+f+fXURfFx25DM4Xrl3PWSk+aGYUHNl X-Received: by 2002:a17:907:20a6:: with SMTP id pw6mr14940373ejb.111.1565296153397; Thu, 08 Aug 2019 13:29:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565296153; cv=none; d=google.com; s=arc-20160816; b=NgFW+MLlruBTGdwmrWxfFv08tADu9N8jp7x8yfLKHPa2lyCU8ndDVaw3X4+TPbO2Cb R9CV9VfeyancRCBwcHctTUvCwMaJVwfkEsg+YlPt4V/gtq2oA6XRdEmTmWa2RaM9+uyq YIkWz81ukIzLN56CvDQjp3GTOQP5DVxj1pSk7Ge2rxZmgCwCdmLMrdLDu2YvZgkmYc/+ NPrwngxCTHcwB1fANabBbXuD9l81hHvNlGTBGo676er/brhh4d5SQAYjyWK+SjbS56Wd t0megV21P7NCCQDt5sbUscoq3uJprG8UegSzSCl8kuMCqxWcCFrYXflq5b8Z2akv4Oje vrQg== 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:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=Vnbne/W2wov3KpmwjXJZkwuhxAhaLlZZtxHbTHDmpe4=; b=KCxWACTDRLxmsBPwkjkjO+rPxLcKzPllmcdkTt3hXslodCMgHWs5bvLYlbtT/N4zsE 3Vgqhjp+4+ZGifeuBLy3zV/Js6b5zN3RtJlP9R7Ru0kx9AKksfKYSvjGsPqUejCJwuIF ZUsLlbDQKY6ZX3CY5vsZFlY45Npo4mheyjqsVO+Xs9D3hkgtIk9JbFDh18jolALIdk0X D3pmWidaYdRAsusrAt+V62nSB6BrJj4OCDq3cgeiLq8oeIGleamg8A/RUALxacYGf9KK 6QQl0QMJhkaeyOjw4iBCYw8PPA0xvz3sHYbFL++AFEpjZCFjYDoemBfQp+hNEEm0OecL zJ7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=RIwwXksl; 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 a5si36233271edc.73.2019.08.08.13.29.13 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 08 Aug 2019 13:29:13 -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=RIwwXksl; 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]:55000 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hvp28-0004oy-EZ for patch@linaro.org; Thu, 08 Aug 2019 16:29:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59906) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hvozV-0007GR-HP for qemu-devel@nongnu.org; Thu, 08 Aug 2019 16:26:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hvozU-0001Kr-AB for qemu-devel@nongnu.org; Thu, 08 Aug 2019 16:26:29 -0400 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:42727) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hvozU-0001KX-4z for qemu-devel@nongnu.org; Thu, 08 Aug 2019 16:26:28 -0400 Received: by mail-pf1-x443.google.com with SMTP id q10so44710127pff.9 for ; Thu, 08 Aug 2019 13:26:28 -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:in-reply-to:references; bh=Vnbne/W2wov3KpmwjXJZkwuhxAhaLlZZtxHbTHDmpe4=; b=RIwwXkslgVIYPkHoDmBsybWghAJcH0UDGklI/tuE4EYGEe5a5mATL1CjdAja0LuDGd RuWX3hOAs7y5acmb8fY2Er2k2rGGq28CRuLqiTXpGgV//3/O+hhoH1CeQRcm300yyKR6 4bnxb2DSv+MbAaUs3yoeD4UTuuPpaJS9XvSy4cT7uQXLvago1N7nSZd5gyjR7TeaLg1i f8qyU1EAOXWx6JUHbDmkwYTQ5f1X/jO7zeMstI8s29JOEljzeex9V6uLfcRmzmuBTS+m +H3be5ziHW0Oip2CsTZnVU7ATkJEXl2T65LTxCe9fxs5Hf3UWWdbHaHPtaKojJa5qgpJ +pNw== 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:in-reply-to :references; bh=Vnbne/W2wov3KpmwjXJZkwuhxAhaLlZZtxHbTHDmpe4=; b=X8lKjd1dUc9mpTV6p/gXprvB6vYfNf8qB4NFx+nIaYP8yg01jX6QgYCKotkZg67O5M kRZi/KKWJzbTy5V9J63h1ttAHBzd/ddPnQCTTXh65+t/OyUgYXqPxHs4HoP3D/lG1H1i X8zdIMC8rehyn6by9iiuZmAzdf4z3vmrcLNEwt1FjWuVrQgt1Pgn7sZJdXBMPzLyI3aJ KpmWJ+anZBc0FUmVJfQH38EPcuo5o3Ffpyl/6xJnGIZ/FyOtSi1KB4NTc3Y5qSePYtxy 8sBep6llf+B1vyuPjqmFy+yLTCG5TaSk2vxJkXr4iX4TVWk3pwTfw3B5ADgT3VLlCazR VD8g== X-Gm-Message-State: APjAAAWhbdWYMOtrxerKBBOA/056UakeWnhTWHg+7ASVs1fum2vivZBK dS0xcsTAlBpTDYiqe9NXMJgS3qG8ZwU= X-Received: by 2002:aa7:9118:: with SMTP id 24mr16838473pfh.56.1565295986728; Thu, 08 Aug 2019 13:26:26 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id v12sm2850146pjk.13.2019.08.08.13.26.25 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 08 Aug 2019 13:26:25 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 8 Aug 2019 13:26:15 -0700 Message-Id: <20190808202616.13782-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190808202616.13782-1-richard.henderson@linaro.org> References: <20190808202616.13782-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::443 Subject: [Qemu-devel] [PATCH 6/7] target/arm: Simplify SMMLA, SMMLAR, SMMLS, SMMLSR 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: peter.maydell@linaro.org, qemu-arm@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" All of the inputs to these instructions are 32-bits. Rather than extend each input to 64-bits and then extract the high 32-bits of the output, use tcg_gen_muls2_i32 and other 32-bit generator functions. Signed-off-by: Richard Henderson --- target/arm/translate.c | 72 +++++++++++++++--------------------------- 1 file changed, 26 insertions(+), 46 deletions(-) -- 2.17.1 diff --git a/target/arm/translate.c b/target/arm/translate.c index ddc54e77e4..77154be743 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -391,34 +391,6 @@ static void gen_revsh(TCGv_i32 var) tcg_gen_ext16s_i32(var, var); } -/* Return (b << 32) + a. Mark inputs as dead */ -static TCGv_i64 gen_addq_msw(TCGv_i64 a, TCGv_i32 b) -{ - TCGv_i64 tmp64 = tcg_temp_new_i64(); - - tcg_gen_extu_i32_i64(tmp64, b); - tcg_temp_free_i32(b); - tcg_gen_shli_i64(tmp64, tmp64, 32); - tcg_gen_add_i64(a, tmp64, a); - - tcg_temp_free_i64(tmp64); - return a; -} - -/* Return (b << 32) - a. Mark inputs as dead. */ -static TCGv_i64 gen_subq_msw(TCGv_i64 a, TCGv_i32 b) -{ - TCGv_i64 tmp64 = tcg_temp_new_i64(); - - tcg_gen_extu_i32_i64(tmp64, b); - tcg_temp_free_i32(b); - tcg_gen_shli_i64(tmp64, tmp64, 32); - tcg_gen_sub_i64(a, tmp64, a); - - tcg_temp_free_i64(tmp64); - return a; -} - /* 32x32->64 multiply. Marks inputs as dead. */ static TCGv_i64 gen_mulu_i64_i32(TCGv_i32 a, TCGv_i32 b) { @@ -8872,23 +8844,27 @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) (SMMUL, SMMLA, SMMLS) */ tmp = load_reg(s, rm); tmp2 = load_reg(s, rs); - tmp64 = gen_muls_i64_i32(tmp, tmp2); + tcg_gen_muls2_i32(tmp2, tmp, tmp, tmp2); if (rd != 15) { - tmp = load_reg(s, rd); + tmp3 = load_reg(s, rd); if (insn & (1 << 6)) { - tmp64 = gen_subq_msw(tmp64, tmp); + tcg_gen_sub_i32(tmp, tmp, tmp3); } else { - tmp64 = gen_addq_msw(tmp64, tmp); + tcg_gen_add_i32(tmp, tmp, tmp3); } + tcg_temp_free_i32(tmp3); } if (insn & (1 << 5)) { - tcg_gen_addi_i64(tmp64, tmp64, 0x80000000u); + /* + * Adding 0x80000000 to the 64-bit quantity + * means that we have carry in to the high + * word when the low word has the high bit set. + */ + tcg_gen_shri_i32(tmp2, tmp2, 31); + tcg_gen_add_i32(tmp, tmp, tmp2); } - tcg_gen_shri_i64(tmp64, tmp64, 32); - tmp = tcg_temp_new_i32(); - tcg_gen_extrl_i64_i32(tmp, tmp64); - tcg_temp_free_i64(tmp64); + tcg_temp_free_i32(tmp2); store_reg(s, rn, tmp); break; case 0: @@ -10114,22 +10090,26 @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) } break; case 5: case 6: /* 32 * 32 -> 32msb (SMMUL, SMMLA, SMMLS) */ - tmp64 = gen_muls_i64_i32(tmp, tmp2); + tcg_gen_muls2_i32(tmp2, tmp, tmp, tmp2); if (rs != 15) { - tmp = load_reg(s, rs); + tmp3 = load_reg(s, rs); if (insn & (1 << 20)) { - tmp64 = gen_addq_msw(tmp64, tmp); + tcg_gen_add_i32(tmp, tmp, tmp3); } else { - tmp64 = gen_subq_msw(tmp64, tmp); + tcg_gen_sub_i32(tmp, tmp, tmp3); } + tcg_temp_free_i32(tmp3); } if (insn & (1 << 4)) { - tcg_gen_addi_i64(tmp64, tmp64, 0x80000000u); + /* + * Adding 0x80000000 to the 64-bit quantity + * means that we have carry in to the high + * word when the low word has the high bit set. + */ + tcg_gen_shri_i32(tmp2, tmp2, 31); + tcg_gen_add_i32(tmp, tmp, tmp2); } - tcg_gen_shri_i64(tmp64, tmp64, 32); - tmp = tcg_temp_new_i32(); - tcg_gen_extrl_i64_i32(tmp, tmp64); - tcg_temp_free_i64(tmp64); + tcg_temp_free_i32(tmp2); break; case 7: /* Unsigned sum of absolute differences. */ gen_helper_usad8(tmp, tmp, tmp2);