From patchwork Thu Aug 8 20:26:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11084721 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C01F61398 for ; Thu, 8 Aug 2019 20:28:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B2E3F285B5 for ; Thu, 8 Aug 2019 20:28:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A6B1B28BC3; Thu, 8 Aug 2019 20:28:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5DEA628BAA for ; Thu, 8 Aug 2019 20:28:08 +0000 (UTC) Received: from localhost ([::1]:54986 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hvp15-0003MR-LP for patchwork-qemu-devel@patchwork.kernel.org; Thu, 08 Aug 2019 16:28:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59760) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hvozO-0006xA-JI for qemu-devel@nongnu.org; Thu, 08 Aug 2019 16:26:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hvozN-0001E8-Ma for qemu-devel@nongnu.org; Thu, 08 Aug 2019 16:26:22 -0400 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]:45946) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hvozN-0001By-HO for qemu-devel@nongnu.org; Thu, 08 Aug 2019 16:26:21 -0400 Received: by mail-pg1-x541.google.com with SMTP id o13so44619955pgp.12 for ; Thu, 08 Aug 2019 13:26:21 -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=otP5Jhfl1E+0A9Fm71GI7ndCATRFA/GRNsznhHQJJms=; b=U6D/k8pueOnINcKO96ewDohrHmZ87S9SdidjRs0w8n/eTVuJGDAiOHNgUnmrhpiRGP 0RIQ+LDvf7kDPtG6QBd+2OR7P7aVhpmAJm1A9BzZva7KSutWjNwzR7MWyitBzJhsjiLo X4svsBqMWpGXLlwgsher8u03wIP7xwcPPX6ncHlWCqt5mOJxoa1zDYxx2G98g8eqD1Hd 5jm/663k6yxKiDdxjUlRLuYS9gY8yz8rLibCJJtwasI703ZrQZLhM3HvycsF2Jj4LORs jbul/lBhoawVT4/LLWTCCSiubqe/G71gIiHi0TwqMGKsTKjxB/2FLh+Nqu/vrV5CasZC qVkA== 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=otP5Jhfl1E+0A9Fm71GI7ndCATRFA/GRNsznhHQJJms=; b=T/WNZ73Y0J3vSsJwAWlTUF1jeh0rBJuZ7cktHML0HUi9/b8quV7G6kGSKOfd9OO+rO v+KxynhPeM2aymmQo1i0qgzk8MNB2iun35hb2aFZ7N3fxvQUbSF2Jq5EeTM1io8SIpxT LBGgNI6bqtRUOVXtz/0sncGvy4RuFgtF+/wpFDcHJZZEoysvKXje1z+Gvy2VvFNZ6hEw 0qFpL5V7po/RxkqQXL6bRjoKJ8glKzI9V/NnVkc/2zibALNR0EO03InjKXo+KnC0jGg3 cmMMXCiWkG+2rhefjJ01zRlKBW0bosvRCpyz+wOQuwH6zBLrxYjyc52DuKZMaSdFj6cX 08VA== X-Gm-Message-State: APjAAAUNCFncZGa9hIma6qbyoxcrrZ6I/rLrtFSSe367uSjNQsjUIEdO kGa+ZL0QDimAxumALSLH/fiIgmxusWY= X-Google-Smtp-Source: APXvYqyPwcefWh1KAjv0oTHqMKVFP2QPZMVO8kBz9MlGRum/pKAPadR0Ir5VT8VtqIlLZNzZcvW4cQ== X-Received: by 2002:a17:90a:2008:: with SMTP id n8mr5763309pjc.4.1565295979981; Thu, 08 Aug 2019 13:26:19 -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.18 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 08 Aug 2019 13:26:19 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 8 Aug 2019 13:26:10 -0700 Message-Id: <20190808202616.13782-2-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::541 Subject: [Qemu-devel] [PATCH 1/7] target/arm: Use tcg_gen_extract_i32 for shifter_out_im 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Extract is a compact combination of shift + and. Signed-off-by: Richard Henderson --- target/arm/translate.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/target/arm/translate.c b/target/arm/translate.c index 846052acea..43e005d191 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -620,14 +620,7 @@ static void gen_sar(TCGv_i32 dest, TCGv_i32 t0, TCGv_i32 t1) static void shifter_out_im(TCGv_i32 var, int shift) { - if (shift == 0) { - tcg_gen_andi_i32(cpu_CF, var, 1); - } else { - tcg_gen_shri_i32(cpu_CF, var, shift); - if (shift != 31) { - tcg_gen_andi_i32(cpu_CF, cpu_CF, 1); - } - } + tcg_gen_extract_i32(cpu_CF, var, shift, 1); } /* Shift by immediate. Includes special handling for shift == 0. */ From patchwork Thu Aug 8 20:26:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11084711 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 320C41398 for ; Thu, 8 Aug 2019 20:27:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 25BE828726 for ; Thu, 8 Aug 2019 20:27:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1AAB128BAA; Thu, 8 Aug 2019 20:27:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BBCF428726 for ; Thu, 8 Aug 2019 20:27:00 +0000 (UTC) Received: from localhost ([::1]:54952 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hvozy-0000Hl-7d for patchwork-qemu-devel@patchwork.kernel.org; Thu, 08 Aug 2019 16:26:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59793) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hvozQ-0006yi-0c for qemu-devel@nongnu.org; Thu, 08 Aug 2019 16:26:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hvozO-0001FS-V4 for qemu-devel@nongnu.org; Thu, 08 Aug 2019 16:26:23 -0400 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:40800) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hvozO-0001F0-Pp for qemu-devel@nongnu.org; Thu, 08 Aug 2019 16:26:22 -0400 Received: by mail-pf1-x442.google.com with SMTP id p184so44721210pfp.7 for ; Thu, 08 Aug 2019 13:26:22 -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=h5Yd6DdTtsmby24hx/qMc8uUeIQaxSevj10drk1jtIY=; b=li+g5mWavems3tksgkMZq3hJ9EOkVKYmGHT+B/KsA1qEQ6FcVD/xNWJpaH/BKO7q/V 4ze8IUbDi4v+DBlMLcNBT0I6s1P1F0DPMSGVKYujQaj+2spoJ8yApsRUfwTNtdFOisnW N+o5T8oXhAN9j2xKJ+2cz1Um3LlNkyWxkRrmeM4Smlx2iC2x/PKoGxUhXRV1Hi6lCS2J otjdKO8jyxQZjaYkPNwJqRCAFr6VRWn74uFVSHrE9v+8SeGwMQ3Mcwn1zNSRPTOLFGMR i+aVWsTAt9WlGVYsNuoKNVGeXACrhZcKUSvIFunRUR99CLl6UMag9uBcCg4x8lApj3Yf F1cQ== 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=h5Yd6DdTtsmby24hx/qMc8uUeIQaxSevj10drk1jtIY=; b=GyWUMlE023zautPAiTLN3d+e22EypFaEiZQrN1QrjtRcHjTo0rE43O49/IEgccO8hb lR9TG0+sUcmmYy0ptyktUC6ZNP41C43jz2ROjlRGOlO0k72aBAjFrzLOuUN+Tf3wiI91 jqGn+JH7jgGpezW5Tj1anRbHUPnu+GeeUpjW4VZltoG35WPBkGSSoNPIjidOtSPvodqi nNK1Q3JaoHt4fztk69eqkV3MB6XuBkUvzxGNZVK2zS0FDncVlivP8v5D/XtgZ86Ptvp9 2p1N0LeOohPNtLGeWrqS0CsHU4Qo3gVUwSJZ1bLzccmTI+4wqX7lXLwI66IVlA9Fsb8i RMHQ== X-Gm-Message-State: APjAAAXIpYwIkaPI345abLcw/iObTf96hJAYVSzP5ddCzZJQV+uMzN5q c1b7E184RpUAYqQyNKdaSvOsivD8oa4= X-Google-Smtp-Source: APXvYqx0Te5xyAo4s/HA/bKsAxaN+WGhZmXvollxyn7Rr9UzhUyJ6DA9XARQKmuCe+qlJS1Zl8+b5g== X-Received: by 2002:a62:cd45:: with SMTP id o66mr17681624pfg.112.1565295981490; Thu, 08 Aug 2019 13:26:21 -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.20 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 08 Aug 2019 13:26:20 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 8 Aug 2019 13:26:11 -0700 Message-Id: <20190808202616.13782-3-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::442 Subject: [Qemu-devel] [PATCH 2/7] target/arm: Use tcg_gen_deposit_i32 for PKHBT, PKHTB 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Use deposit as the composit operation to merge the bits from the two inputs. Signed-off-by: Richard Henderson --- target/arm/translate.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/target/arm/translate.c b/target/arm/translate.c index 43e005d191..94170af134 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -8769,19 +8769,16 @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) shift = (insn >> 7) & 0x1f; if (insn & (1 << 6)) { /* pkhtb */ - if (shift == 0) + if (shift == 0) { shift = 31; + } tcg_gen_sari_i32(tmp2, tmp2, shift); - tcg_gen_andi_i32(tmp, tmp, 0xffff0000); - tcg_gen_ext16u_i32(tmp2, tmp2); + tcg_gen_deposit_i32(tmp, tmp, tmp2, 0, 16); } else { /* pkhbt */ - if (shift) - tcg_gen_shli_i32(tmp2, tmp2, shift); - tcg_gen_ext16u_i32(tmp, tmp); - tcg_gen_andi_i32(tmp2, tmp2, 0xffff0000); + tcg_gen_shli_i32(tmp2, tmp2, shift); + tcg_gen_deposit_i32(tmp, tmp2, tmp, 0, 16); } - tcg_gen_or_i32(tmp, tmp, tmp2); tcg_temp_free_i32(tmp2); store_reg(s, rd, tmp); } else if ((insn & 0x00200020) == 0x00200000) { @@ -9817,19 +9814,16 @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) shift = ((insn >> 10) & 0x1c) | ((insn >> 6) & 0x3); if (insn & (1 << 5)) { /* pkhtb */ - if (shift == 0) + if (shift == 0) { shift = 31; + } tcg_gen_sari_i32(tmp2, tmp2, shift); - tcg_gen_andi_i32(tmp, tmp, 0xffff0000); - tcg_gen_ext16u_i32(tmp2, tmp2); + tcg_gen_deposit_i32(tmp, tmp, tmp2, 0, 16); } else { /* pkhbt */ - if (shift) - tcg_gen_shli_i32(tmp2, tmp2, shift); - tcg_gen_ext16u_i32(tmp, tmp); - tcg_gen_andi_i32(tmp2, tmp2, 0xffff0000); + tcg_gen_shli_i32(tmp2, tmp2, shift); + tcg_gen_deposit_i32(tmp, tmp2, tmp, 0, 16); } - tcg_gen_or_i32(tmp, tmp, tmp2); tcg_temp_free_i32(tmp2); store_reg(s, rd, tmp); } else { From patchwork Thu Aug 8 20:26:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11084719 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 075091398 for ; Thu, 8 Aug 2019 20:28:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EF7572873D for ; Thu, 8 Aug 2019 20:28:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E074828BBF; Thu, 8 Aug 2019 20:28:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8602F2873D for ; Thu, 8 Aug 2019 20:28:07 +0000 (UTC) Received: from localhost ([::1]:54984 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hvp14-0003Km-Ok for patchwork-qemu-devel@patchwork.kernel.org; Thu, 08 Aug 2019 16:28:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59817) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hvozR-00071Z-0g for qemu-devel@nongnu.org; Thu, 08 Aug 2019 16:26:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hvozQ-0001Ho-0F for qemu-devel@nongnu.org; Thu, 08 Aug 2019 16:26:24 -0400 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:44742) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hvozP-0001G4-Qy for qemu-devel@nongnu.org; Thu, 08 Aug 2019 16:26:23 -0400 Received: by mail-pf1-x444.google.com with SMTP id t16so44696427pfe.11 for ; Thu, 08 Aug 2019 13:26:23 -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=KppSBSLgqldeUIFCtJ9vyMILLmhpVP0HjXn8WOkkAA4=; b=WnwvmjTrnJNDu8FpkcTfajv3YXkp1HDXgKJRDnJsh4LeprPE+rotaDg4ArlBy1pUqi MZLBz7rc+F9xOy/MNt81VkGgqzO4Jdw8I394H1auRIe6ugilnMZs6WQBakXrAZebVnOp smUm8YPLbU5Vi9kD5cFR3zfwYvniUefvxMMqshlui48xAy59hVauPkjscWOFwMRyl1ZY YT1bQp7hM+l0T6qpOP7uH9oGv81z0mAKikO87668goWxo3r6FHp8MtDg6aUy1Rk9KOr/ ++9updJ2Yp6+tALpTW8JV1s47nUe0LrhWt9jmdUvdrSLGVm4ce9DYHCu+PSvZoKu5QSy mCBQ== 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=KppSBSLgqldeUIFCtJ9vyMILLmhpVP0HjXn8WOkkAA4=; b=snEYsuxS1X9GW5PtwQB2N67POEddrc9JEAnHbJGtJVx2SSOjeL0MEaSMRrXm/3tbZB isqZuoBOTbi2WeBBPvb4mb87qXuVAqftvsAJE7QoexBsZFiqVw9JRtyE4NX0iRhQUbFp Rb5HeWwhFH0183LZMnLlAmbW999tP0b5cJsDPv3I9hsUW8XPU/tdmZRbsSiarmPJhIqb 3YjtlLA7PyW3EgfO7hVzMENEjWehywmZevlVL/XVBjNGPWgN+sBosOpCU6mkByDNEHq+ hnf1hIUcyR2jO/G7hiB9VrRiMEuvHZjWQoS/hWqgD99F4rK3mszfUUSPsGilrYdX8X/c R/TA== X-Gm-Message-State: APjAAAXUbhxnVsX4s4PnQWKkRk8yUzNuGjQbXxOiDHHy38OQheT6CKvB ghW5SPKQbZQvjHZi+S+ynqHFOdFzQLA= X-Google-Smtp-Source: APXvYqyRqEzzbb30wen7bTbdUzD/fS5VaTAp+LTO/o6EPXhMrHB7vKvkSGhFZOBNiYUp+Bld5dhnjQ== X-Received: by 2002:a17:90a:2305:: with SMTP id f5mr6123614pje.128.1565295982598; Thu, 08 Aug 2019 13:26:22 -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.21 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 08 Aug 2019 13:26:21 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 8 Aug 2019 13:26:12 -0700 Message-Id: <20190808202616.13782-4-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::444 Subject: [Qemu-devel] [PATCH 3/7] target/arm: Remove redundant shift tests 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The immediate shift generator functions already test for, and eliminate, the case of a shift by zero. Signed-off-by: Richard Henderson --- target/arm/translate.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/target/arm/translate.c b/target/arm/translate.c index 94170af134..3ddc404b3b 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -8826,8 +8826,7 @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) shift = (insn >> 10) & 3; /* ??? In many cases it's not necessary to do a rotate, a shift is sufficient. */ - if (shift != 0) - tcg_gen_rotri_i32(tmp, tmp, shift * 8); + tcg_gen_rotri_i32(tmp, tmp, shift * 8); op1 = (insn >> 20) & 7; switch (op1) { case 0: gen_sxtb16(tmp); break; @@ -9904,8 +9903,7 @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) shift = (insn >> 4) & 3; /* ??? In many cases it's not necessary to do a rotate, a shift is sufficient. */ - if (shift != 0) - tcg_gen_rotri_i32(tmp, tmp, shift * 8); + tcg_gen_rotri_i32(tmp, tmp, shift * 8); op = (insn >> 20) & 7; switch (op) { case 0: gen_sxth(tmp); break; @@ -10632,11 +10630,10 @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) case 7: goto illegal_op; default: /* Saturate. */ - if (shift) { - if (op & 1) - tcg_gen_sari_i32(tmp, tmp, shift); - else - tcg_gen_shli_i32(tmp, tmp, shift); + if (op & 1) { + tcg_gen_sari_i32(tmp, tmp, shift); + } else { + tcg_gen_shli_i32(tmp, tmp, shift); } tmp2 = tcg_const_i32(imm); if (op & 4) { @@ -10827,9 +10824,7 @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) goto illegal_op; } tmp = load_reg(s, rm); - if (shift) { - tcg_gen_shli_i32(tmp, tmp, shift); - } + tcg_gen_shli_i32(tmp, tmp, shift); tcg_gen_add_i32(addr, addr, tmp); tcg_temp_free_i32(tmp); break; From patchwork Thu Aug 8 20:26:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11084713 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EF1E213B1 for ; Thu, 8 Aug 2019 20:27:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E295B2878F for ; Thu, 8 Aug 2019 20:27:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D63E328BAA; Thu, 8 Aug 2019 20:27:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8605828BC6 for ; Thu, 8 Aug 2019 20:27:08 +0000 (UTC) Received: from localhost ([::1]:54954 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hvp07-0000QA-Tk for patchwork-qemu-devel@patchwork.kernel.org; Thu, 08 Aug 2019 16:27:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59852) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hvozS-00075E-At for qemu-devel@nongnu.org; Thu, 08 Aug 2019 16:26:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hvozR-0001Iv-BP for qemu-devel@nongnu.org; Thu, 08 Aug 2019 16:26:26 -0400 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:34206) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hvozR-0001IE-6H for qemu-devel@nongnu.org; Thu, 08 Aug 2019 16:26:25 -0400 Received: by mail-pf1-x443.google.com with SMTP id b13so44724458pfo.1 for ; Thu, 08 Aug 2019 13:26:25 -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=nqzQU642U0COih1CmgjWbkQy5lirJcAcLB93HWWBZtw=; b=f4x3IifJ5NF4+rRGiMDD/6mffiSedpgiTboNBBfCNIUABOKv4uEyTedewTSTZGif2G OK3b6LiDTatS2yds7cbMJsul3xUL73d5M/A221BuTd/xCE+bP/c4q3rYpsCE9/s//biT y3byX0n20EyREj7D6Qp9/o0kFA1E8M/qHp1mvSQzn+ITbz8Bxx8rSqiQV2T/7oRqUtFg evltcs0K+vibzQ3Af5AO9WH23zdK1+TCgXzmBrvQFmQt/bMha1dgxJgCJD3//k0qgjN0 /9KvgZIFtlhXRpQfSOzIU+ZqpLVBqC/X1Hs/ZqgVnoJMnWF2LVTceAtBb5jCLyZpX976 InIg== 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=nqzQU642U0COih1CmgjWbkQy5lirJcAcLB93HWWBZtw=; b=ZCjm+lht42sn1y3f5hvrBU1wkCvYvjbvCPFTA8xwnPUC9TXXzlUH6d8t8Ef/cl6m0m hqfOw1XipMbSvnIfqx6nRoOJDMozf8MURAWyvPbQn5KS+iMNy37f8WfLau7VjFD7LEUG sdeRttFRS8JSnYw7xYJRd/isUOFxDj376h+HsbFs19AtBVXC8u17O9KPPpkawuSUW1Ck gkcpNz/1X5+w9rlnUgDxqvuzB/JH41F8g5us3G/VC9ei6qqX5b/64RLMLIIl/xmCvlvd S2uRx8Q3oWC1VYcLhXJF8jyR4V/h4MlnzjCNokyTOZ8eSF8Ergw9H3csgpig2Cd2rVZz oOeQ== X-Gm-Message-State: APjAAAW7z9ZT3NSoNmRlJQR1dWJun6QK7X4cXAKnsEcccD1dUPHF9aw3 2C0FZ5TK8TyUCRJBdPIIYcTdY/jD7eY= X-Google-Smtp-Source: APXvYqxBoha2CfxdKMixIZb3G2CsT6uFGiBuX1rzJKdj/9McrVOkHD9PY8588KeXAtZLb8f1sRXRlg== X-Received: by 2002:a17:90a:3aed:: with SMTP id b100mr5814407pjc.63.1565295983855; Thu, 08 Aug 2019 13:26:23 -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.22 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 08 Aug 2019 13:26:22 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 8 Aug 2019 13:26:13 -0700 Message-Id: <20190808202616.13782-5-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 4/7] target/arm: Use ror32 instead of open-coding the operation 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The helper function is more documentary, and also already handles the case of rotate by zero. Signed-off-by: Richard Henderson --- target/arm/translate.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/target/arm/translate.c b/target/arm/translate.c index 3ddc404b3b..b40f163bab 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -7979,8 +7979,7 @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) /* CPSR = immediate */ val = insn & 0xff; shift = ((insn >> 8) & 0xf) * 2; - if (shift) - val = (val >> shift) | (val << (32 - shift)); + val = ror32(val, shift); i = ((insn & (1 << 22)) != 0); if (gen_set_psr_im(s, msr_mask(s, (insn >> 16) & 0xf, i), i, val)) { @@ -8243,9 +8242,7 @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) /* immediate operand */ val = insn & 0xff; shift = ((insn >> 8) & 0xf) * 2; - if (shift) { - val = (val >> shift) | (val << (32 - shift)); - } + val = ror32(val, shift); tmp2 = tcg_temp_new_i32(); tcg_gen_movi_i32(tmp2, val); if (logic_cc && shift) { From patchwork Thu Aug 8 20:26:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11084715 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 43B4A13B1 for ; Thu, 8 Aug 2019 20:27:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 36AE52873D for ; Thu, 8 Aug 2019 20:27:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 24A3728BBF; Thu, 8 Aug 2019 20:27:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CE8CE28BAA for ; Thu, 8 Aug 2019 20:27:09 +0000 (UTC) Received: from localhost ([::1]:54956 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hvp09-0000Wr-50 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 08 Aug 2019 16:27:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59877) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hvozT-00078q-Gv for qemu-devel@nongnu.org; Thu, 08 Aug 2019 16:26:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hvozS-0001Ju-KW for qemu-devel@nongnu.org; Thu, 08 Aug 2019 16:26:27 -0400 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:37152) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hvozS-0001JR-Dp for qemu-devel@nongnu.org; Thu, 08 Aug 2019 16:26:26 -0400 Received: by mail-pg1-x543.google.com with SMTP id d1so11820218pgp.4 for ; Thu, 08 Aug 2019 13:26:26 -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=RskjHA12b+UCLX2htP8k3zX7fIXUBDlXhLLJAVERdC0=; b=AI5BNglKzJ2nl0bwk9cg0D/RBrxrCsZPjYtJwwhMbI6xLE29xO9oKjooujma6sBJDH x2TUbnqhBThgU9jAt4HatoRJLmXHeXgo5yIkfDaPdIm1Vsq7X7zMIunrC2IIgbBR93Fr wOilkONR8MFHcXpVSAGnr4kaG2RBJbv+DQMQeh79a66RbhJZG5UrT0LX//EMqTqlXAwD fbkfNYZd8LKN5OlCz1UJzA8gX+uF0PyEG06FvnJJRaLm25VVk73Y70SR0bYd6LjBTr2k nu9JHSO92ppTRl3J5IT74hgWQR1bcMKiX5V+FP/7jwhtSD3BEsAZ3i9l7uQa8KL1FQ8B SKbQ== 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=RskjHA12b+UCLX2htP8k3zX7fIXUBDlXhLLJAVERdC0=; b=GvrjGOMiwmXHfs+6dHXhZjJGT0er3Dw1vzLYR/hVGffPfOf0jqNMjWoNMbvU/OHunI clDnmD8ULjylD7BbmuKCl0AEbxjllx34JusHG8iIsqsh998vilVjV1Bm1kclCcM3ExBK lbAN3prS3T1SoXjopHr+S22GTqTlV4kpu+1IxOL8VwoBCDpcREbKqX7zDkdzaqOgi/8b de3qFZRnht+2XFV1PiAUoT0BYlItmacQWrLY/DDwAqoqS8YeFgf2OD5ruOkkWMkT57GO SqjFubg/5scBmBS3zZ1OYg+DQpbljSJOeoBueyH+1l+HseLGdPp+8aLMFFtXrWON+Wy3 4Vpw== X-Gm-Message-State: APjAAAV6/bXTzeE6S7SHjYaoauf5eSTLjZP342i5T6edmUx8WK99HNi5 xsGLDHQ/IaDYZ925PYjRWmY93GXUTQA= X-Google-Smtp-Source: APXvYqx3IbAmTAUljRT3n2vxLgD+LJf7v1V+KLJeb9XaYVru7wLRBwWXMuzN9B5pdU089+acRCaAJg== X-Received: by 2002:a17:90a:9bc5:: with SMTP id b5mr5853080pjw.109.1565295985125; Thu, 08 Aug 2019 13:26:25 -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.23 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 08 Aug 2019 13:26:24 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 8 Aug 2019 13:26:14 -0700 Message-Id: <20190808202616.13782-6-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::543 Subject: [Qemu-devel] [PATCH 5/7] target/arm: Use tcg_gen_rotri_i32 for gen_swap_half 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Rotate is the more compact and obvious way to swap 16-bit elements of a 32-bit word. Signed-off-by: Richard Henderson --- target/arm/translate.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/target/arm/translate.c b/target/arm/translate.c index b40f163bab..ddc54e77e4 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -459,11 +459,7 @@ static TCGv_i64 gen_muls_i64_i32(TCGv_i32 a, TCGv_i32 b) /* Swap low and high halfwords. */ static void gen_swap_half(TCGv_i32 var) { - TCGv_i32 tmp = tcg_temp_new_i32(); - tcg_gen_shri_i32(tmp, var, 16); - tcg_gen_shli_i32(var, var, 16); - tcg_gen_or_i32(var, var, tmp); - tcg_temp_free_i32(tmp); + tcg_gen_rotri_i32(var, var, 16); } /* Dual 16-bit add. Result placed in t0 and t1 is marked as dead. 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: 11084723 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5E07013B1 for ; Thu, 8 Aug 2019 20:29:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 51E9128BAA for ; Thu, 8 Aug 2019 20:29:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 468AE28BC3; Thu, 8 Aug 2019 20:29:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CCD7128BAA for ; Thu, 8 Aug 2019 20:29:15 +0000 (UTC) Received: from localhost ([::1]:55007 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hvp2B-0005eC-7R for patchwork-qemu-devel@patchwork.kernel.org; Thu, 08 Aug 2019 16:29:15 -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-Google-Smtp-Source: APXvYqweMZWhgG5RUAQ3DWddb6tRHcBzimB3t2gBAGpO/hDWx4+vHrT0+xw3DoBjlwTRuAZHneNHCQ== 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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); From patchwork Thu Aug 8 20:26:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11084725 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1529513B1 for ; Thu, 8 Aug 2019 20:29:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 08B5A28876 for ; Thu, 8 Aug 2019 20:29:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F14B828BBF; Thu, 8 Aug 2019 20:29:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 977BF28876 for ; Thu, 8 Aug 2019 20:29:17 +0000 (UTC) Received: from localhost ([::1]:55008 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hvp2C-0005i5-UB for patchwork-qemu-devel@patchwork.kernel.org; Thu, 08 Aug 2019 16:29:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59929) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hvozW-0007Jb-HK for qemu-devel@nongnu.org; Thu, 08 Aug 2019 16:26:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hvozV-0001M1-Cs for qemu-devel@nongnu.org; Thu, 08 Aug 2019 16:26:30 -0400 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]:40928) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hvozV-0001LH-7i for qemu-devel@nongnu.org; Thu, 08 Aug 2019 16:26:29 -0400 Received: by mail-pg1-x541.google.com with SMTP id w10so44637956pgj.7 for ; Thu, 08 Aug 2019 13:26:29 -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=AcVFjfcusS5dLWT70g3h9t3XMQa4NwJ2WZoNCoEA3tk=; b=zTL5AmxUG1HAJtBxREkWCohQIuU5e/eWoOKXPgWm7cdi0Cbss+jzaqR6Cg1inkf3SO sq2EDEt4l/rv1s2oe38z8PvIGuDlQzmmbCBBA6QzAG9SefWWPADeq1INm7dLYBdJX4HC vBG4ppvGAaHNRbitrkMJ4PvW+990yBCMyS8loSTnCkZ1z+9ebmINaItqXl1bBP2Qi+mN DMKzOIJ8TvW7ga4DCdH8KgiLAcNKqv/vZ/vUtdOF5Uz3uyAdgLZw+Qgi0ri5JfkejdpF Bif9+rNE+1wwVHlzmHM0IihBf+GGLDXnhAl5a+NZvLtkTPXkKuNpdhyoeprGe7H9E+eZ GSfw== 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=AcVFjfcusS5dLWT70g3h9t3XMQa4NwJ2WZoNCoEA3tk=; b=hSjucfHX2XqerOs9pAViNjSAcDM3CDZ9zW6Nx5OgDx3tU2BsAek1y15N9c+AiaXOnn LZtMGA+bH9nKZX+k9nxAond842CYyODOu0XXiowtm/WGyILMjIveD2FpOT0sKBCFuXbY J/0s4vMF0JGwg8qAvMpXgs4wB5DmZZ4VUoYXvjNar8OftGqGHDQITEMokVtf4+BgmDHA zHitYvyng/34g+X47etWsTPjPZSj+ImIXTsO8bMuKTUr7KRp4xpg1W+fT14WCu58T/Um 6ZWy7nOnWgHY20XUE2rDcki/zJDGRJ0tgTZNUuK0xtphjku/9lnsvM400oO3wHO0Ww8k KWhw== X-Gm-Message-State: APjAAAXpOn4pI/iOEvhPVi/HAH8/ZEQpu6x0NNnECSRy48K+EZUas9Tx e3ksxI0kmhyhCoYqqZ/Sswz55o1SJQg= X-Google-Smtp-Source: APXvYqx088HeJxF82vXyFaLKETFEBxPPvjb49mIQDVxDs3bQLjcHrTZXfQq0DIXxqhxFIV0qWBIbrg== X-Received: by 2002:aa7:8b51:: with SMTP id i17mr17664848pfd.33.1565295987980; Thu, 08 Aug 2019 13:26:27 -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.26 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 08 Aug 2019 13:26:27 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 8 Aug 2019 13:26:16 -0700 Message-Id: <20190808202616.13782-8-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::541 Subject: [Qemu-devel] [PATCH 7/7] target/arm: Use tcg_gen_extrh_i64_i32 to extract the high word 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Separate shift + extract low will result in one extra insn for hosts like RISC-V, MIPS, and Sparc. Signed-off-by: Richard Henderson --- target/arm/translate.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/target/arm/translate.c b/target/arm/translate.c index 77154be743..9e103e4fad 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -1761,8 +1761,7 @@ static int disas_iwmmxt_insn(DisasContext *s, uint32_t insn) if (insn & ARM_CP_RW_BIT) { /* TMRRC */ iwmmxt_load_reg(cpu_V0, wrd); tcg_gen_extrl_i64_i32(cpu_R[rdlo], cpu_V0); - tcg_gen_shri_i64(cpu_V0, cpu_V0, 32); - tcg_gen_extrl_i64_i32(cpu_R[rdhi], cpu_V0); + tcg_gen_extrh_i64_i32(cpu_R[rdhi], cpu_V0); } else { /* TMCRR */ tcg_gen_concat_i32_i64(cpu_V0, cpu_R[rdlo], cpu_R[rdhi]); iwmmxt_store_reg(cpu_V0, wrd); @@ -2807,8 +2806,7 @@ static int disas_dsp_insn(DisasContext *s, uint32_t insn) if (insn & ARM_CP_RW_BIT) { /* MRA */ iwmmxt_load_reg(cpu_V0, acc); tcg_gen_extrl_i64_i32(cpu_R[rdlo], cpu_V0); - tcg_gen_shri_i64(cpu_V0, cpu_V0, 32); - tcg_gen_extrl_i64_i32(cpu_R[rdhi], cpu_V0); + tcg_gen_extrh_i64_i32(cpu_R[rdhi], cpu_V0); tcg_gen_andi_i32(cpu_R[rdhi], cpu_R[rdhi], (1 << (40 - 32)) - 1); } else { /* MAR */ tcg_gen_concat_i32_i64(cpu_V0, cpu_R[rdlo], cpu_R[rdhi]); @@ -6005,8 +6003,7 @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) gen_helper_neon_narrow_high_u16(tmp, cpu_V0); break; case 2: - tcg_gen_shri_i64(cpu_V0, cpu_V0, 32); - tcg_gen_extrl_i64_i32(tmp, cpu_V0); + tcg_gen_extrh_i64_i32(tmp, cpu_V0); break; default: abort(); } @@ -6020,8 +6017,7 @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) break; case 2: tcg_gen_addi_i64(cpu_V0, cpu_V0, 1u << 31); - tcg_gen_shri_i64(cpu_V0, cpu_V0, 32); - tcg_gen_extrl_i64_i32(tmp, cpu_V0); + tcg_gen_extrh_i64_i32(tmp, cpu_V0); break; default: abort(); } @@ -7254,9 +7250,8 @@ static int disas_coproc_insn(DisasContext *s, uint32_t insn) tmp = tcg_temp_new_i32(); tcg_gen_extrl_i64_i32(tmp, tmp64); store_reg(s, rt, tmp); - tcg_gen_shri_i64(tmp64, tmp64, 32); tmp = tcg_temp_new_i32(); - tcg_gen_extrl_i64_i32(tmp, tmp64); + tcg_gen_extrh_i64_i32(tmp, tmp64); tcg_temp_free_i64(tmp64); store_reg(s, rt2, tmp); } else { @@ -7365,8 +7360,7 @@ static void gen_storeq_reg(DisasContext *s, int rlow, int rhigh, TCGv_i64 val) tcg_gen_extrl_i64_i32(tmp, val); store_reg(s, rlow, tmp); tmp = tcg_temp_new_i32(); - tcg_gen_shri_i64(val, val, 32); - tcg_gen_extrl_i64_i32(tmp, val); + tcg_gen_extrh_i64_i32(tmp, val); store_reg(s, rhigh, tmp); }