From patchwork Sun Jun 18 07:07:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takayuki 'January June' Suwa X-Patchwork-Id: 1796219 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=WTVmiXvL; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QkPFn16g0z20Wg for ; Sun, 18 Jun 2023 17:11:25 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 465473857C48 for ; Sun, 18 Jun 2023 07:11:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 465473857C48 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1687072282; bh=kImRHuycDAIEXkVaARckS9HKvZ7pC8RB5wjzirA8g58=; h=Date:To:Cc:Subject:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=WTVmiXvLenB1pbzvJd9bvBkKy8TxhMG1CUsEn14vpqihwvAlOKerqeJDao8ozjc/o Zav51yAjQ30lFB0SVYmB4mpfKYfU6S8ZEmJHyWzYSrOGySaqowOFE8Wb3pO3virLDq Zwgnu0Wv+SdkCf5+qkWEvrF83a8+YiIE9sb4rvLU= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from omggw0013-vm1.mail.otm.yahoo.co.jp (omggw0013-vm1.mail.otm.yahoo.co.jp [182.22.18.211]) by sourceware.org (Postfix) with ESMTPS id A8EA93858D20 for ; Sun, 18 Jun 2023 07:10:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A8EA93858D20 X-YMail-OSG: Ipg4e_EVM1mGWO5TnPpTsU0JRL.Gjy2BSLw4nzkrBGgABg3WnH.Q7n3_JYjX9lA ghSOF1ekLSdHikd7F1EoE9pBqjzgLP.2oQSxOwD9Pgou2F8T2snPy_XgnjgFO_HXH_HpfjzKY07U 0wokH2_X9l0rcMbEXlvR.gBkh77SwVGsSJ9ery9hOf5B7LygS3hZ2K5rr0n5tzqlFZN8g5X_dOVr jvmZc4HeSxdPix0IjquSgJcV7Zq9U3gL5VdX.RjA.0jfGGZopP5fVJrCJPMJZ3HCP0DEN2GjuYU1 yESXSC72YdBrTtgUxug3ff2ddcpQXm8Xy4t_Kz4oWYW2YalSUQguoM0ddTPAYDHizcSoQj9mO3L8 w3p.y_5OscPfQcg_AMYXupCihnsKkenSymeeJX4yibW1surF2tM7gbWzwHXXxGALNHXwXHbwAfAp f9qfpLi.wXmy49mvTfjU6OKNRNyY86YTglYrlgXM_D7quxpk_rhFyO8IIQsrOLcMciZ_E_EkyxMD 0qF9wBcvjrIZK34xHbKsjJt_MZZ5tqhvOpafN8dPW6Ctp31o_ODISeajxeVxsPlRERUO435j0Zrp 8x8dDd_a2nbtMj.kecmxsgL2bYWdFIHX1MZmkd2laGp7OuAoC_Bf.jx8ekT58CuYp0lDEuC10UCd dJXTYKIr9lCVGOH0xKwImGQgR_NWNClHmUjmZy5UVUb8wZAcPxkSfFqP5g2iwVAGvZLp2fu4Zc_. QONkAA8VxfNclEoaLysBjTg65vDu9feyw9R4jkFJJ2jJA1DAHu1D6Gss.5_kosuA9bbzTo08WmE5 XwRBNv3omRiOuxC2V8TV.bMrRR4jfZo1Mi0FzSWgd3rFcFP8rWbXjfoFnrsKXj0Nd58sApU8_Cv2 JbtoMTePrguPDYZMd2HyIKtlw.rWe8UkNx02WmUf9McDf89teHjxG_Fp0XPYbpsUd_qu.95co.5a xst50OzYXlwEBdngYKttkBm9MEO252tbLCOVWK493.NK6eG2xRVjvlq_Wh.Q354Na5A-- Received: from sonicgw.mail.yahoo.co.jp by sonicconh6002.mail.ssk.yahoo.co.jp with HTTP; Sun, 18 Jun 2023 07:10:03 +0000 Received: by smtphe5003.mail.kks.ynwp.yahoo.co.jp (YJ Hermes SMTP Server) with ESMTPA ID 9d48f23be46a11a199b917a14162a6a4; Sun, 18 Jun 2023 16:10:01 +0900 (JST) Message-ID: <9e970f70-52e4-183e-b6af-91f62607793d@yahoo.co.jp> Date: Sun, 18 Jun 2023 16:07:12 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 To: GCC Patches Cc: Max Filippov Subject: [PATCH 1/2] xtensa: Remove TARGET_MEMORY_MOVE_COST hook References: <9e970f70-52e4-183e-b6af-91f62607793d.ref@yahoo.co.jp> X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Takayuki 'January June' Suwa via Gcc-patches From: Takayuki 'January June' Suwa Reply-To: Takayuki 'January June' Suwa Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" It used to always return a constant 4, which is same as the default behavior, but doesn't take into account the effects of secondary reloads. Therefore, the implementation of this target hook is removed. gcc/ChangeLog: * config/xtensa/xtensa.cc (TARGET_MEMORY_MOVE_COST, xtensa_memory_move_cost): Remove. --- gcc/config/xtensa/xtensa.cc | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/gcc/config/xtensa/xtensa.cc b/gcc/config/xtensa/xtensa.cc index 3b5d25b660a..721c99b56a3 100644 --- a/gcc/config/xtensa/xtensa.cc +++ b/gcc/config/xtensa/xtensa.cc @@ -131,7 +131,6 @@ static bool xtensa_rtx_costs (rtx, machine_mode, int, int, int *, bool); static int xtensa_insn_cost (rtx_insn *, bool); static int xtensa_register_move_cost (machine_mode, reg_class_t, reg_class_t); -static int xtensa_memory_move_cost (machine_mode, reg_class_t, bool); static tree xtensa_build_builtin_va_list (void); static bool xtensa_return_in_memory (const_tree, const_tree); static tree xtensa_gimplify_va_arg_expr (tree, tree, gimple_seq *, @@ -213,8 +212,6 @@ static rtx xtensa_delegitimize_address (rtx); #undef TARGET_REGISTER_MOVE_COST #define TARGET_REGISTER_MOVE_COST xtensa_register_move_cost -#undef TARGET_MEMORY_MOVE_COST -#define TARGET_MEMORY_MOVE_COST xtensa_memory_move_cost #undef TARGET_RTX_COSTS #define TARGET_RTX_COSTS xtensa_rtx_costs #undef TARGET_INSN_COST @@ -4356,16 +4353,6 @@ xtensa_register_move_cost (machine_mode mode ATTRIBUTE_UNUSED, return 10; } -/* Worker function for TARGET_MEMORY_MOVE_COST. */ - -static int -xtensa_memory_move_cost (machine_mode mode ATTRIBUTE_UNUSED, - reg_class_t rclass ATTRIBUTE_UNUSED, - bool in ATTRIBUTE_UNUSED) -{ - return 4; -} - /* Compute a (partial) cost for rtx X. Return true if the complete cost has been computed, and false if subexpressions should be scanned. In either case, *TOTAL contains the cost result. */ From patchwork Sun Jun 18 07:09:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takayuki 'January June' Suwa X-Patchwork-Id: 1796218 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=Ls7e8hVa; dkim-atps=neutral Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QkPDk22GXz20Wg for ; Sun, 18 Jun 2023 17:10:29 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DA7F4385842B for ; Sun, 18 Jun 2023 07:10:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DA7F4385842B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1687072226; bh=v02Hp8Mib3YTkFlC0dW/Zb18kvN0klXW42jqmF78gmc=; h=Date:To:Cc:Subject:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=Ls7e8hVaJVzPkIMm0zWFWmZpmBx/67z9k2vMQoV+iD/CEQIhUlWF3iOITflAn0QCQ JjOB4VV+L7uwbH4ih5eFFKM9j+LnfVuwjn3wf6jFOlKcxJxO+Xv9QQqaebGeTyHWfu /mC05qO08CzM+ImjjLFSMi8p64wKRh3jpw5r0S9o= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from omggw7003-vm0.mail.djm.yahoo.co.jp (omggw7003-vm0.mail.djm.yahoo.co.jp [183.79.54.80]) by sourceware.org (Postfix) with ESMTPS id B4C183858D28 for ; Sun, 18 Jun 2023 07:10:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B4C183858D28 X-YMail-OSG: H2MQZJMVM1lTTpWKWDRJa8ArZC6ErYDlHJSZylqiE0xlTl.VaWEIO.YPmprFb8v qKTqYGRLDC1TN5g5b.TKvTLq.CWSvpkJcKDqZB6RUEm6M2TcjPwGsJ7VFRmDfXLPexCip.BcIOhj IbWmDV.Y3F6F9oGofQ9nIAruAQHdyALoJMZItdeMnak0IfcaGAEtjGOO_NAX6rETSNHybp3Smy0W AboxLZcvlffI_eR5Dgwl6rMM8uXstTETOzYdPZ3OPDkizutTb3zl93Fh14lxZdSyKLlYphjsGoxq 9p80SYat5KNiTQRJhElX6tNK9tMIolihKCgIwtV076mT5_r4kQOKceUCw97OQsTpIX7o_PZjSlZj mE3EBxSjmTQx53qWRAKxxAesEBx3HDi.qzxakHCT8dHgC6ClFpEeJUkgyLi6IMvdoyRz1qQmWepl luJfzSlDwqHPWguJH_z1FXDT.Oym0jjewbFbc_pAmdAJdanU66PzMicfGF1VB_gfYfpAuKJd41BP 4kX6G_SzyMHDeWUrP__wywL.2HEU9kOv.7wRwk.aecFrtobXBVPS6VUGINdBWf5FVRr3Q22kJ1RZ ynwgJCDEp6ORmfWAqQ1tVsS5Jf3iWIHehx9MWJlp7RXm_HdehY9qG..AhRssWBEtIWyiuXrmpKMI j8C1wPdFLN1LqsUtro3efyminmhSoodjDvSKexlfKUv3AaoX1gJLj0C1l7LHbPtmLVRywCT6nzT5 m8pBdNS2vQ04wHDxiqNPi1LDUaSmJK7dBVzluQ0BU2mkWWSkmNdsKg.mxH80o9nmEU8J864fbet4 MO9uV0kww5mOevXnTUI5f1JeJgAf948DmYMk.VcFDaSKijUC55bkxUaj4y7EjhisovQDc4Wd5f0U Ou2gYg7G2Squu1OiwBsDNN5h.KsZIaPTzQ3fjXd2X04IoOhxChIe5DAZKiClXG2aGVo_SnkFHHsq PSkwRasSdE5mgsHy11cO6JXs1H9jKIobx4loX2I_zOs_6IGVGiSTMOW7NQ9upTfiPng-- Received: from sonicgw.mail.yahoo.co.jp by sonicconh5003.mail.kks.yahoo.co.jp with HTTP; Sun, 18 Jun 2023 07:10:04 +0000 Received: by smtphe5004.mail.kks.ynwp.yahoo.co.jp (YJ Hermes SMTP Server) with ESMTPA ID 6405f330ee5b96ba24a50548f4bbb68e; Sun, 18 Jun 2023 16:10:02 +0900 (JST) Message-ID: Date: Sun, 18 Jun 2023 16:09:10 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 To: GCC Patches Cc: Max Filippov Subject: [PATCH 2/2] xtensa: constantsynth: Add new 2-insns synthesis pattern References: X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Takayuki 'January June' Suwa via Gcc-patches From: Takayuki 'January June' Suwa Reply-To: Takayuki 'January June' Suwa Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" This patch adds a new 2-instructions constant synthesis pattern: - A non-negative square value that root can fit into a signed 12-bit: => "MOVI(.N) Ax, simm12" + "MULL Ax, Ax, Ax" Due to the execution cost of the integer multiply instruction (MULL), this synthesis works only when the 32-bit Integer Multiply Option is configured and optimize for size is specified. gcc/ChangeLog: * config/xtensa/xtensa.cc (xtensa_constantsynth_2insn): Add new pattern for the abovementioned case. --- gcc/config/xtensa/xtensa.cc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/gcc/config/xtensa/xtensa.cc b/gcc/config/xtensa/xtensa.cc index 721c99b56a3..dd35e63c094 100644 --- a/gcc/config/xtensa/xtensa.cc +++ b/gcc/config/xtensa/xtensa.cc @@ -58,6 +58,7 @@ along with GCC; see the file COPYING3. If not see #include "insn-attr.h" #include "tree-pass.h" #include "print-rtl.h" +#include /* This file should be included last. */ #include "target-def.h" @@ -1067,7 +1068,7 @@ xtensa_constantsynth_2insn (rtx dst, HOST_WIDE_INT srcval, { HOST_WIDE_INT imm = INT_MAX; rtx x = NULL_RTX; - int shift; + int shift, sqr; gcc_assert (REG_P (dst)); @@ -1078,7 +1079,6 @@ xtensa_constantsynth_2insn (rtx dst, HOST_WIDE_INT srcval, x = gen_lshrsi3 (dst, dst, GEN_INT (32 - shift)); } - shift = ctz_hwi (srcval); if ((!x || (TARGET_DENSITY && ! IN_RANGE (imm, -32, 95))) && xtensa_simm12b (srcval >> shift)) @@ -1105,6 +1105,14 @@ xtensa_constantsynth_2insn (rtx dst, HOST_WIDE_INT srcval, x = gen_addsi3 (dst, dst, GEN_INT (imm1)); } + sqr = (int) floorf (sqrtf (srcval)); + if (TARGET_MUL32 && optimize_size + && !x && IN_RANGE (srcval, 0, (2047 * 2047)) && sqr * sqr == srcval) + { + imm = sqr; + x = gen_mulsi3 (dst, dst, dst); + } + if (!x) return 0;