From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=yahoo.co.jp Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=yahoo.co.jp 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 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1687072204; s=yj20110701; d=yahoo.co.jp; h=Message-ID:Date:MIME-Version:To:Cc:From:Subject:Content-Type:Content-Transfer-Encoding:References; bh=v02Hp8Mib3YTkFlC0dW/Zb18kvN0klXW42jqmF78gmc=; b=oH5UrVMkXKeFnVJGWcLo8ux+35pGAFNG/jJFgfAmX9ft3KB4JeCfvv08q2EaTJIE v3IFBaKP47jvah8hEW3M0/Vxy6BUtoA9m0Ly5Q81pUyXlxT75gxFAoab0N6IW3K9SBY si5cDkY7pohDJ1iAfOBs2PTr1qlJ9XmLtqDejv+g= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=yj20110701; d=yahoo.co.jp; h=Message-ID:Date:MIME-Version:Cc:From:Content-Type:Content-Transfer-Encoding:References; b=evRJ2b/L/zy67KxKb+Elift6EVKEnrUczNVQxgRexf6XaHF9tX+9ZeW8URadY6VK KFonB+qWpa1j5C0cAUcdh4hkN7+T8fAuuWN2C6GhhETOPXBP6DBwrJLFqrmKaU1k2Qi 9FQIGkXDh6EoMB10s/S/luBFqapdChTvd4qlqXEg=; 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 From: Takayuki 'January June' Suwa Subject: [PATCH 2/2] xtensa: constantsynth: Add new 2-insns synthesis pattern Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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 List-Id: 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; -- 2.30.2