From patchwork Wed Mar 8 06:04:41 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: 66109 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AFA4638515DB for ; Wed, 8 Mar 2023 06:05:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AFA4638515DB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1678255520; bh=GXRkEwJ1315BRMBHGEegLW5SWt+Il8zo5Qs1lofRt1o=; h=Date:To:Cc:Subject:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=WuputnjvYjYF9P6EzOiGYBKGOCki6DfOm3WVVCyG4dBZB1t/fQPVqrg8tLKdsYqLM 4QVwSIENDLYfCIiZCVxNq/HjQgb0dni8AAugPk2xJ3adOQTT4+omJkanWjGml/Lk5y GoRPwQXBWJoZmxJExqQmUCUZYQElM93RMlb2AmYM= 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 699973858410 for ; Wed, 8 Mar 2023 06:04:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 699973858410 X-YMail-OSG: Tzi0YBUVM1kYgD7HH04hB.PIzv0vgIVaWlI_o0XRhus5GauDbhm9DebtZUqo4Gm d0_Cn7nCjgxxgtfAM1FVXWmW8DQtjl70fxzMRjmmbPbWEuKtQ39tbUlyoiSyjY.0gAk6efdyqdsH Oy7HcWW9KWHly5xd_dqLFPGRiTkLeKbeydICA9xSUQ0MSb5NQrnFBkHmIWEz153Z_zSSEBI5EA44 XDG4tQ2STu5wPB6kPQay3E8YkR6venaTP71bmiJdgs4XwUB2lqXVrRlzpl20ojlpYeI1Ahl1HqSz .UxPjz2Z5qEhj5jV5yMmksM0re3jvdyV2FBokLm_Mj1yM4A601ZYLlz3R6MknQpiCiLKchiJVu0o O_hXfLtLWevnnDm1brbyL8JwBLlgr62M2iY9cCmAswNlXtTmHhSglRPmPUZnyro07RqoaCJqB1IQ 53ZTNUVAvaxOgl1X4UpH5Xp5.PhPTaY9.8exnRi5twP8JUTcBcn7HTFWrJm5IUZtsqLS2QDQikba m0aQ2D_URlyzIig9VhGkExu1MEB.sTynn2oCMfapfb2QX7qYbDdxNFbTK4no8m18.Bo7AfJFPOIZ KjS2wvR8peeaQr5y4HMCBB8b3YEzqUQOhDHC7B6jRF2IIq.MX5aHDlAQ1wQbt.N6dI7Jjbseirca 7U4NUMVMwCKX7GqKKN5JC6KxzrCyqUgWOYDb.NWb0f84YAMxBwsW.RUQ3_1XlxqUZCqPL403GuaK J2xan.Iv_lObbyu6x0kvCR.HOUweKPofd8gFFXXHCKZ7wKPQsfPhsaZWjY65YtyjijDSEf4ksFHV x9dfw0Ex589AOcnvoO61IITLfVrOLOFepkeR0HR.x5Bcxto2nkmV4fNQwnxSpuIWpm0QfNWIT2Bh gks2LDHaOls1Vr4u6NxtLE5U_JcAo6Ni8xwcmpLhjAIAfH.4nQVYBH4zz1PIyq1qzzOsu5lmVXlp pyibPra7X5jyJaOudnHfIux2x0Od2BFSR7H15pQJmW4tgvzX0szuzaUBlJwXqfVGKHWb5 Received: from sonicgw.mail.yahoo.co.jp by sonicconh6003.mail.ssk.yahoo.co.jp with HTTP; Wed, 8 Mar 2023 06:04:47 +0000 Received: by smtphe6010.mail.ssk.ynwp.yahoo.co.jp (YJ Hermes SMTP Server) with ESMTPA ID ef5c8bc802badda87e37b37c57177dc3; Wed, 08 Mar 2023 15:04:41 +0900 (JST) Message-ID: <8a826036-e109-9ffb-7048-b5bbaab22590@yahoo.co.jp> Date: Wed, 8 Mar 2023 15:04:41 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 To: GCC Patches Cc: Max Filippov Subject: [PATCH] xtensa: Fix for enabling LRA References: <8a826036-e109-9ffb-7048-b5bbaab22590.ref@yahoo.co.jp> X-Spam-Status: No, score=-12.1 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+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" This patch makes LRA well with some exceptions (e.g. MI thunk generation due to pretending reload_completed). gcc/ChangeLog: * config/xtensa/constraints.md (R, T, U): Change define_constraint to define_memory_constraint. * config/xtensa/xtensa.cc (xtensa_legitimate_constant_p): Add short-circuit path for integer load instructions when lra_in_progress. * config/xtensa/xtensa.md (movsf): Use can_create_pseudo_p() rather reload_in_progress and reload_completed. --- gcc/config/xtensa/constraints.md | 26 ++++++++------------------ gcc/config/xtensa/xtensa.cc | 4 ++++ gcc/config/xtensa/xtensa.md | 2 +- 3 files changed, 13 insertions(+), 19 deletions(-) diff --git a/gcc/config/xtensa/constraints.md b/gcc/config/xtensa/constraints.md index 53e4d0d8dd1..9b31e162941 100644 --- a/gcc/config/xtensa/constraints.md +++ b/gcc/config/xtensa/constraints.md @@ -123,29 +123,19 @@ (and (match_code "const_int") (match_test "! xtensa_split1_finished_p ()")))) -;; Memory constraints. Do not use define_memory_constraint here. Doing so -;; causes reload to force some constants into the constant pool, but since -;; the Xtensa constant pool can only be accessed with L32R instructions, it -;; is always better to just copy a constant into a register. Instead, use -;; regular constraints but add a check to allow pseudos during reload. +;; Memory constraints. -(define_constraint "R" +(define_memory_constraint "R" "Memory that can be accessed with a 4-bit unsigned offset from a register." - (ior (and (match_code "mem") - (match_test "smalloffset_mem_p (op)")) - (and (match_code "reg") - (match_test "reload_in_progress - && REGNO (op) >= FIRST_PSEUDO_REGISTER")))) + (and (match_code "mem") + (match_test "smalloffset_mem_p (op)"))) -(define_constraint "T" +(define_memory_constraint "T" "Memory in a literal pool (addressable with an L32R instruction)." (and (match_code "mem") (match_test "!TARGET_CONST16 && constantpool_mem_p (op)"))) -(define_constraint "U" +(define_memory_constraint "U" "Memory that is not in a literal pool." - (ior (and (match_code "mem") - (match_test "! constantpool_mem_p (op)")) - (and (match_code "reg") - (match_test "reload_in_progress - && REGNO (op) >= FIRST_PSEUDO_REGISTER")))) + (and (match_code "mem") + (match_test "! constantpool_mem_p (op)"))) diff --git a/gcc/config/xtensa/xtensa.cc b/gcc/config/xtensa/xtensa.cc index 7287aa7a258..a500dc2a06e 100644 --- a/gcc/config/xtensa/xtensa.cc +++ b/gcc/config/xtensa/xtensa.cc @@ -4872,6 +4872,10 @@ xtensa_trampoline_init (rtx m_tramp, tree fndecl, rtx chain) static bool xtensa_legitimate_constant_p (machine_mode mode ATTRIBUTE_UNUSED, rtx x) { + if (lra_in_progress && CONST_INT_P (x)) + return TARGET_AUTO_LITPOOLS || TARGET_CONST16 + || xtensa_simm12b (INTVAL (x)); + return !xtensa_tls_referenced_p (x); } diff --git a/gcc/config/xtensa/xtensa.md b/gcc/config/xtensa/xtensa.md index 3521fa33b47..195515d9427 100644 --- a/gcc/config/xtensa/xtensa.md +++ b/gcc/config/xtensa/xtensa.md @@ -1268,7 +1268,7 @@ if ((!register_operand (operands[0], SFmode) && !register_operand (operands[1], SFmode)) || (FP_REG_P (xt_true_regnum (operands[0])) - && !(reload_in_progress | reload_completed) + && can_create_pseudo_p () && (constantpool_mem_p (operands[1]) || CONSTANT_P (operands[1])))) operands[1] = force_reg (SFmode, operands[1]);