public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-64] dse: Use SUBREG_REG for copy_to_mode_reg in DSE replace_read for WORD_REGISTER_OPERATIONS targets [P
@ 2023-04-19  9:13 Jakub Jelinek
  0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2023-04-19  9:13 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:76f44fbfea1f11e53d4b7e83f0debd029c94a1b3

commit r14-64-g76f44fbfea1f11e53d4b7e83f0debd029c94a1b3
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Apr 19 11:13:11 2023 +0200

    dse: Use SUBREG_REG for copy_to_mode_reg in DSE replace_read for WORD_REGISTER_OPERATIONS targets [PR109040]
    
    While we've agreed this is not the right fix for the PR109040 bug,
    the patch clearly improves generated code (at least on the testcase from the
    PR), so I'd like to propose this as optimization heuristics improvement
    for GCC 14.
    
    2023-04-19  Jakub Jelinek  <jakub@redhat.com>
    
            PR target/109040
            * dse.cc (replace_read): If read_reg is a SUBREG of a word mode
            REG, for WORD_REGISTER_OPERATIONS copy SUBREG_REG of it into
            a new REG rather than the SUBREG.

Diff:
---
 gcc/dse.cc | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/gcc/dse.cc b/gcc/dse.cc
index a2db8d1cc32..802b949cfb2 100644
--- a/gcc/dse.cc
+++ b/gcc/dse.cc
@@ -2012,7 +2012,19 @@ replace_read (store_info *store_info, insn_info_t store_insn,
     }
   /* Force the value into a new register so that it won't be clobbered
      between the store and the load.  */
-  read_reg = copy_to_mode_reg (read_mode, read_reg);
+  if (WORD_REGISTER_OPERATIONS
+      && GET_CODE (read_reg) == SUBREG
+      && REG_P (SUBREG_REG (read_reg))
+      && GET_MODE (SUBREG_REG (read_reg)) == word_mode)
+    {
+      /* For WORD_REGISTER_OPERATIONS with subreg of word_mode register
+	 force SUBREG_REG into a new register rather than the SUBREG.  */
+      rtx r = copy_to_mode_reg (word_mode, SUBREG_REG (read_reg));
+      read_reg = shallow_copy_rtx (read_reg);
+      SUBREG_REG (read_reg) = r;
+    }
+  else
+    read_reg = copy_to_mode_reg (read_mode, read_reg);
   insns = get_insns ();
   end_sequence ();

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-04-19  9:13 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-19  9:13 [gcc r14-64] dse: Use SUBREG_REG for copy_to_mode_reg in DSE replace_read for WORD_REGISTER_OPERATIONS targets [P Jakub Jelinek

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).