From patchwork Thu Jan 12 04:25:58 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: 1724884 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=SHeIhpY2; 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 4Nss226LjWz23fd for ; Thu, 12 Jan 2023 15:26:33 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6C8B23858D35 for ; Thu, 12 Jan 2023 04:26:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6C8B23858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1673497590; bh=gMIMU6u2vBNKV4S0qFnjbdmWlR+TtB8QmkNIxWgtggo=; h=Date:To:Cc:Subject:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=SHeIhpY2HfEFGVW6uQxpoG+8tOH0knuWvKeTcOWQ712kDTKt9vHimU3BaZ0NbayIe XpZLFl2+pOmWgEFX8RAAib741/cmDdCktmQJzhiXccoF0/gt9oQZzM1vBGo2l7pzDO oNQcVMTy8EXbEitFRQ/675JFXAZjxQcwyzqwwJhk= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from sonicconh6003-vm1.mail.ssk.yahoo.co.jp (sonicconh6003-vm1.mail.ssk.yahoo.co.jp [182.22.37.42]) by sourceware.org (Postfix) with ESMTPS id E2C423858D35 for ; Thu, 12 Jan 2023 04:26:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E2C423858D35 X-YMail-OSG: 8HmTiskVM1nigenpg1fdNph_BLWZ4YDnpieAX1jsrGVniCXCzji758C4Z05.r4i uAOJxTI7MboogQuhw2DdHSzEUwI2jFDO1iLE6ZTSzh5bV6reVjjtcjtcnFlD9mqRnJq_xP6BiJax Rum5NrqMQFTw0hxhx5ibTNPROnLvo2gDPGgSTlIlwSf2Ciq1mgARnxwJZmH7J5D0vSC1bZRH96N7 hklBo9yo7LwjAzr1.82q49iijIimAqeEsb0omJvDfTwzJJPFzu2zxUnuZE1BgeB0cDGjjPtG9rAQ cl0HWmDjFlSzwfaXrTnsh6zgHKqUeI1rRHRR_lSbUku.6XE.wkEs2ApujGejQN2tU0ZVTfJWzJlN VrLgbK8Pn.EYIEv.4KJinxgqrJbZMVFTUqPUrOOmpvnaLvP1i.0.E0iEVfeFxUkyA8E_Pz16Z.2J hhgK9DTIXjCL3P0tZXA7VYBLF54ZQWg6L0au1na2nhc7kC2UaluRhdNKy1EuCGwNhPzM_FgClQdy Wvc8OYwzUo.P7XwyHc.gGlVqU3k6ZtI5HB07V5op59jqswE0.xIbMcBEvFMvaxIGvVBo8HxGBEf5 TaruOErPEmW1ah2ychTO3Ar_RdnI4dVDtyOliZjQ_faTKDRIQGNjnbhbiiNzQTgnqq6K8yT3xWE2 ITVTa7HErQGCBXoFAQKvra2K_tb66uBx8AV8R5jporZPhkhKG.Q2roHqPCgXTw5gQ80wXRiLcES1 3I9LKnAIcuo._musWY1fvF31EOPNpXHcHXTji_jbu3nCOckW_Lk1Tcvx8VHbr8UVOKLZrS7E_O62 UZtnZHrVr7oN5j2mWQ.nKzwYyXCO0DFas0TuuNwQb5SlhFBMWAKGv7QE3EC7Rmub3MEKXwWcgd.N 1_0EmMzy.UFdRRgeT_ZAVONEim7rbL4ffdMuAy_AfNY83nUOS6ZiqOUk26FmRv51bWndtzOWmq1W RqkjXmik- Received: from sonicgw.mail.yahoo.co.jp by sonicconh6003.mail.ssk.yahoo.co.jp with HTTP; Thu, 12 Jan 2023 04:26:03 +0000 Received: by smtphe5001.mail.kks.ynwp.yahoo.co.jp (YJ Hermes SMTP Server) with ESMTPA ID 3de18a13078614ebaf115c7a15cb6cd7; Thu, 12 Jan 2023 13:25:59 +0900 (JST) Message-ID: <92692f27-76e3-ce45-bc25-95b9a7d2b64f@yahoo.co.jp> Date: Thu, 12 Jan 2023 13:25:58 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 To: GCC Patches Cc: Max Filippov Subject: [PATCH 1/2] xtensa: Tune "*btrue" insn pattern References: <92692f27-76e3-ce45-bc25-95b9a7d2b64f.ref@yahoo.co.jp> X-Spam-Status: No, score=-11.6 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 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 branch instruction has short encoding if EQ/NE comparison against immediate zero when the Code Density Option is enabled, but its "length" attribute was only for normal encoding. This patch fixes it. This patch also prevents undesireable replacement the comparison immediate zero of the instruction (short encoding, as mentioned above) with a register that has value of zero (normal encoding) by the postreload pass. gcc/ChangeLog: * config/xtensa/xtensa.md (*btrue): Correct value of the attribute "length" that depends on TARGET_DENSITY and operands, and add '?' character to the register constraint of the compared operand. --- gcc/config/xtensa/xtensa.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/gcc/config/xtensa/xtensa.md b/gcc/config/xtensa/xtensa.md index db1d68ee658..b4989832169 100644 --- a/gcc/config/xtensa/xtensa.md +++ b/gcc/config/xtensa/xtensa.md @@ -1679,7 +1679,7 @@ [(set (pc) (if_then_else (match_operator 3 "branch_operator" [(match_operand:SI 0 "register_operand" "r,r") - (match_operand:SI 1 "branch_operand" "K,r")]) + (match_operand:SI 1 "branch_operand" "K,?r")]) (label_ref (match_operand 2 "" "")) (pc)))] "" @@ -1688,7 +1688,14 @@ } [(set_attr "type" "jump,jump") (set_attr "mode" "none") - (set_attr "length" "3,3")]) + (set (attr "length") + (if_then_else (match_test "TARGET_DENSITY + && CONST_INT_P (operands[1]) + && INTVAL (operands[1]) == 0 + && (GET_CODE (operands[3]) == EQ + || GET_CODE (operands[3]) == NE)") + (const_int 2) + (const_int 3)))]) (define_insn "*ubtrue" [(set (pc) From patchwork Thu Jan 12 04:26:42 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: 1724885 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=cwbx91LB; 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 4Nss345C6qz23fd for ; Thu, 12 Jan 2023 15:27:28 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AEB22385B518 for ; Thu, 12 Jan 2023 04:27:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AEB22385B518 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1673497646; bh=dgAJJ2IWOmFDsbueVc83orSGguMHHrk+JbtR+1Plxs0=; h=Date:To:Cc:Subject:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=cwbx91LBeb9mpBFQBtwhjOuKZT4TZowiQfUFTBLsBL95yNeLP6KB8exWfS3wXPwJf lzvq95nMwpMkzZFs90irxZ/WbGt057uU57fzACVhoPGDhJ52eSyPI4FMzZQScGfVEL Kw+KHsA4vvSfh//UpdyCI2ENcA8INdCPGcS26sCY= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from sonicconh6001-vm2.mail.ssk.yahoo.co.jp (sonicconh6001-vm2.mail.ssk.yahoo.co.jp [182.22.37.11]) by sourceware.org (Postfix) with ESMTPS id 0B5C83856975 for ; Thu, 12 Jan 2023 04:26:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0B5C83856975 X-YMail-OSG: 4MFaVi8VM1m.xV0otYNqx8smCrC38b18b1KwMi6YlYNMFo2OygG_zfW3jfY0RRi ZxiMUCiVBsG83SzqSS_.EooaUvN89JpHknuKaPPjqioEbLX7f9LZ_iUcQUtQaQ5QTzkS7g4XeyAA e3C2G7SVRB9i4OBes9wEmJRYP2MjOaO0lgAY.uKUKkH9TBJzDKJibTFGLD7qCf4vJG9oKnchjqnC MbVFP22XiEAPF_h2vps00tYkkbiPBqjGduYmRIMUYdqB.y3dCpPkEAkZurl7jD3xXrWiZCt1.hLm WU6TdrLa_3dZYsJmiOp78DGWbpdMhxCLfmAyNZhyQ5LSvGFuqfAD1FzkLOgNIzibudi2PmkuY0Yr UkpV2NjRGtFk9cYE50saUeaQpY0tsBsHeJo8NLEPNyHIy_Rv_lVFwO0anMNoNd264BpfMC1sDYGX tQ97QAQYrjJ5dKgUviMJjIdS_0tlK_JFfT7LBKBS6bKwaup7ThFnfW282zmAaWW7GhAlAzZY5KeJ PaKm4MlwK9XzXFEx4t3newBaVL_LGEvOp1vLoE1ziAtkB698FTW16S2WOxRj2li5En2HYM3xZfDf GYIRs6FjFsUt7QVlLIpycw4OTAPIWcl_IhpS3NP9gAs2xETecwRqKbukOJqCaKC4wgp5lTP7gKau 6_H9VSAuxLRGhMSLEm78D7GyEo2xQmlsaptqKllJBotd650oiBHTf4tyrUweUwZjfqnMr3K6ue2B Up7lf9_g5r5UWs5iagCdEW9qzcjLnHgD.RAX0aN8GaeWMBHumX.wtbrY8AlEasR9fPjvBE74TeeL o_IMPSj4FvSKblEmJnnpdHz4e8urZc3tO0nsdRbpLb94B5hQwJy_sUhAFCcrUIgGeV3yl7JDscX5 1eR8vPvM0Jv76DcYX0E4CQhKKYrwdE3lwWWbZZi7GK4nSEhX1L5abC7_iprIOpuBon6hXD9xQOzR kdjAwFE8- Received: from sonicgw.mail.yahoo.co.jp by sonicconh6001.mail.ssk.yahoo.co.jp with HTTP; Thu, 12 Jan 2023 04:26:45 +0000 Received: by smtphe5006.mail.kks.ynwp.yahoo.co.jp (YJ Hermes SMTP Server) with ESMTPA ID 4af41384d4fe308683cd1350d1b18f61; Thu, 12 Jan 2023 13:26:44 +0900 (JST) Message-ID: Date: Thu, 12 Jan 2023 13:26:42 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 To: GCC Patches Cc: Max Filippov Subject: [PATCH 2/2] xtensa: Optimize ctzsi2 and ffssi2 a bit References: X-Spam-Status: No, score=-12.4 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 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 saves one byte when the Code Density Option is enabled, gcc/ChangeLog: * config/xtensa/xtensa.md (ctzsi2, ffssi2): Rearrange the emitting codes. --- gcc/config/xtensa/xtensa.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gcc/config/xtensa/xtensa.md b/gcc/config/xtensa/xtensa.md index b4989832169..764da63f91c 100644 --- a/gcc/config/xtensa/xtensa.md +++ b/gcc/config/xtensa/xtensa.md @@ -477,8 +477,8 @@ emit_insn (gen_negsi2 (temp, operands[1])); emit_insn (gen_andsi3 (temp, temp, operands[1])); emit_insn (gen_clzsi2 (temp, temp)); - emit_insn (gen_negsi2 (temp, temp)); - emit_insn (gen_addsi3 (operands[0], temp, GEN_INT (31))); + emit_move_insn (operands[0], GEN_INT (31)); + emit_insn (gen_subsi3 (operands[0], operands[0], temp)); DONE; }) @@ -491,8 +491,8 @@ emit_insn (gen_negsi2 (temp, operands[1])); emit_insn (gen_andsi3 (temp, temp, operands[1])); emit_insn (gen_clzsi2 (temp, temp)); - emit_insn (gen_negsi2 (temp, temp)); - emit_insn (gen_addsi3 (operands[0], temp, GEN_INT (32))); + emit_move_insn (operands[0], GEN_INT (32)); + emit_insn (gen_subsi3 (operands[0], operands[0], temp)); DONE; })