public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Max Filippov <jcmvbkbc@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r13-1123] xtensa: Eliminate unwanted reg-reg moves during DFmode input reloads
Date: Wed, 15 Jun 2022 23:59:36 +0000 (GMT)	[thread overview]
Message-ID: <20220615235936.D57AB385627D@sourceware.org> (raw)

https://gcc.gnu.org/g:cfad4856fa46abc878934a9433d0bfc2482ccf00

commit r13-1123-gcfad4856fa46abc878934a9433d0bfc2482ccf00
Author: Takayuki 'January June' Suwa <jjsuwa_sys3175@yahoo.co.jp>
Date:   Tue Jun 14 12:39:49 2022 +0900

    xtensa: Eliminate unwanted reg-reg moves during DFmode input reloads
    
    When spilled DFmode registers are reloaded in, once loaded into a pair of
    SImode regs and then copied from that regs.  Such unwanted reg-reg moves
    seems not to be eliminated at the "cprop_hardreg" stage, despite no problem
    in output reloads.
    
    Luckily it is easy to resolve such inefficiencies, with the use of peephole2
    pattern.
    
    gcc/ChangeLog:
    
            * config/xtensa/predicates.md (reload_operand):
            New predicate.
            * config/xtensa/xtensa.md: New peephole2 pattern.

Diff:
---
 gcc/config/xtensa/predicates.md | 13 +++++++++++++
 gcc/config/xtensa/xtensa.md     | 31 +++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+)

diff --git a/gcc/config/xtensa/predicates.md b/gcc/config/xtensa/predicates.md
index d63a6cf034c..edd13ae41b9 100644
--- a/gcc/config/xtensa/predicates.md
+++ b/gcc/config/xtensa/predicates.md
@@ -165,6 +165,19 @@
   (and (match_code "const_int")
        (match_test "xtensa_mem_offset (INTVAL (op), SFmode)")))
 
+(define_predicate "reload_operand"
+  (match_code "mem")
+{
+  const_rtx addr = XEXP (op, 0);
+  if (REG_P (addr))
+    return REGNO (addr) == A1_REG;
+  if (GET_CODE (addr) == PLUS)
+    return REG_P (XEXP (addr, 0))
+	   && REGNO (XEXP (addr, 0)) == A1_REG
+	   && CONST_INT_P (XEXP (addr, 1));
+  return false;
+})
+
 (define_predicate "branch_operator"
   (match_code "eq,ne,lt,ge"))
 
diff --git a/gcc/config/xtensa/xtensa.md b/gcc/config/xtensa/xtensa.md
index fa2a4a05a25..8ed0ff53a70 100644
--- a/gcc/config/xtensa/xtensa.md
+++ b/gcc/config/xtensa/xtensa.md
@@ -2749,3 +2749,34 @@
 	(if_then_else (match_test "TARGET_DENSITY")
 		      (const_int 5)
 		      (const_int 6)))])
+
+(define_peephole2
+  [(set (match_operand:SI 0 "register_operand")
+	(match_operand:SI 6 "reload_operand"))
+   (set (match_operand:SI 1 "register_operand")
+	(match_operand:SI 7 "reload_operand"))
+   (set (match_operand:SF 2 "register_operand")
+	(match_operand:SF 4 "register_operand"))
+   (set (match_operand:SF 3 "register_operand")
+	(match_operand:SF 5 "register_operand"))]
+  "REGNO (operands[0]) == REGNO (operands[4])
+   && REGNO (operands[1]) == REGNO (operands[5])
+   && peep2_reg_dead_p (4, operands[0])
+   && peep2_reg_dead_p (4, operands[1])"
+  [(set (match_dup 2)
+	(match_dup 6))
+   (set (match_dup 3)
+	(match_dup 7))]
+{
+  uint32_t check = 0;
+  int i;
+  for (i = 0; i <= 3; ++i)
+    {
+      uint32_t mask = (uint32_t)1 << REGNO (operands[i]);
+      if (check & mask)
+	FAIL;
+      check |= mask;
+    }
+  operands[6] = gen_rtx_MEM (SFmode, XEXP (operands[6], 0));
+  operands[7] = gen_rtx_MEM (SFmode, XEXP (operands[7], 0));
+})


                 reply	other threads:[~2022-06-15 23:59 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220615235936.D57AB385627D@sourceware.org \
    --to=jcmvbkbc@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).