diff mbox series

rtl-optimization/101523 - avoid re-combine after noop 2->2 combination

Message ID 20240403110808.5C10E384641E@sourceware.org
State New
Headers show
Series rtl-optimization/101523 - avoid re-combine after noop 2->2 combination | expand

Commit Message

Richard Biener April 3, 2024, 11:07 a.m. UTC
The following avoids re-walking and re-combining the instructions
between i2 and i3 when the pattern of i2 doesn't change.

Bootstrap and regtest running ontop of a reversal of 
r14-9692-g839bc42772ba7a.

It brings down memory use frmo 9GB to 400MB and compile-time from
80s to 3.5s.  r14-9692-g839bc42772ba7a does better in both metrics
but has shown code generation regressions across acrchitectures.

OK to revert r14-9692-g839bc42772ba7a?

OK to install this instead?

Thanks,
Richard.

	PR rtl-optimization/101523
	* combine.cc (try_combine): When the pattern of i2 doesn't
	change do not re-start combining at i2 or an earlier insn which
	had links or notes added.
---
 gcc/combine.cc | 7 +++++++
 1 file changed, 7 insertions(+)
diff mbox series

Patch

diff --git a/gcc/combine.cc b/gcc/combine.cc
index a4479f8d836..ff25752cac4 100644
--- a/gcc/combine.cc
+++ b/gcc/combine.cc
@@ -4186,6 +4186,10 @@  try_combine (rtx_insn *i3, rtx_insn *i2, rtx_insn *i1, rtx_insn *i0,
       adjust_for_new_dest (i3);
     }
 
+  bool i2_unchanged = false;
+  if (rtx_equal_p (newi2pat, PATTERN (i2)))
+    i2_unchanged = true;
+
   /* We now know that we can do this combination.  Merge the insns and
      update the status of registers and LOG_LINKS.  */
 
@@ -4752,6 +4756,9 @@  try_combine (rtx_insn *i3, rtx_insn *i2, rtx_insn *i1, rtx_insn *i0,
   combine_successes++;
   undo_commit ();
 
+  if (i2_unchanged)
+    return i3;
+
   rtx_insn *ret = newi2pat ? i2 : i3;
   if (added_links_insn && DF_INSN_LUID (added_links_insn) < DF_INSN_LUID (ret))
     ret = added_links_insn;