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: 66023 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp160251wrd; Tue, 7 Mar 2023 22:05:36 -0800 (PST) X-Google-Smtp-Source: AK7set/7NNRKBYw1TZ46pzgcPj6WGYe9RuG2JEcg5H2GK1vw3HmTbGD+6d6VrFYI1lpcyM3fKL2m X-Received: by 2002:a17:907:64c:b0:8ab:a378:5f96 with SMTP id wq12-20020a170907064c00b008aba3785f96mr20637418ejb.3.1678255536848; Tue, 07 Mar 2023 22:05:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678255536; cv=none; d=google.com; s=arc-20160816; b=dhzyjz4G7/BmTQKW0t2fcsJTvzMxk0eDLeHLXqSKh/eKngWN2pY23kLzXVuWLC4bmL /aZ5jAYb40rVltZTEpK2XHN6phVhBiYY5ttzoEixqHI87stbh9lSCQaugN0ZOcIAdHZa fN+2G2JDe7LFOPFWgib8+1QNDnVUNVdYS3jP8D+w9Q5H0WxkvG5SVyGrfd/wCfVaH5ZV mxsjnQgCSPUPsb5H7iBohgcuatRLDLASGzZIS6Fq+Cnn8J4lkaZ4YSQ7FujwSACFyN4m dVJhc/GYR9RJAZxMtlVPOaDXWN9gblmffxcejgSgIueRyaHGDcXRFNwo/x2crD8FMktD j/Ag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:references :content-transfer-encoding:subject:cc:to:user-agent:mime-version :date:message-id:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=GXRkEwJ1315BRMBHGEegLW5SWt+Il8zo5Qs1lofRt1o=; b=wORnPI0rEQgddEBUqy9/tjInp0oyerppRIvS6JoSnWLBhkn25n6AkagzzgyLz5sra7 kVS+kZgGTQOm1/CP4u4f12pnsbC/i7NZ/+4kKXCaBROXkmwzQj2DYJiQAIC0JQNb4wYy 6ROcVxzyn1zBKMVtK+ATAbvVwIEvYDciIQKFC1+LWnti06I2OGV9xuPwM6XkP2Ewyq0w U70gzDqhBlTEeYI2QJWsOugFii8TNzN39S/4qXU7of8a28OSEekh8st7hN80v+o+sYml L/9nAd1Mim6RidTBBfhhYpgtL+GpxtLqDc1Na/avraYk04Mqbw2gyJzEVOlLK6vJ65l1 ZcvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=da1CEzfS; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id hb30-20020a170907161e00b008b85ed1bbc7si7295080ejc.366.2023.03.07.22.05.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Mar 2023 22:05:36 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=da1CEzfS; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A4B4038515C3 for ; Wed, 8 Mar 2023 06:05:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A4B4038515C3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1678255535; 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=da1CEzfSTjBeldtF8VCicPhAC28SdHJueWTEuQDHQ8O0mEW3fSJDEMJXYMtPKEUNV 99khN4Xf1dOAIlq/gzuLlMQpZxxc3xJC8DJJuusBwDRHNl3HqeXm1XwGxFsCAbxjmr Drw2V6HylBMHAT0oR0qH1HSeatJgKVVapwAUUvBA= 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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759778477746504574?= X-GMAIL-MSGID: =?utf-8?q?1759778477746504574?= 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]);