Richard Biener 2024-04-04 07:46:22 +00:00 committed by Git OBS Bridge
parent 6df8046a37
commit d44b58ed57
2 changed files with 27 additions and 29 deletions

View File

@ -1,48 +1,46 @@
From 839bc42772ba7af66af3bd16efed4a69511312ae Mon Sep 17 00:00:00 2001
From: Segher Boessenkool <segher@kernel.crashing.org>
Date: Wed, 27 Mar 2024 14:09:52 +0000
Subject: [PATCH] combine: Don't combine if I2 does not change
From 5729ffad4db78b26f0d1f658a9fd695be5970550 Mon Sep 17 00:00:00 2001
From: Richard Biener <rguenther@suse.de>
Date: Wed, 3 Apr 2024 12:58:26 +0200
Subject: [PATCH] rtl-optimization/101523 - avoid re-combine after noop 2->2
combination
To: gcc-patches@gcc.gnu.org
In some cases combine will "combine" an I2 and I3, but end up putting
exactly the same thing back as I2 as was there before. This is never
progress, so we shouldn't do it, it will lead to oscillating behaviour
and the like.
If we want to canonicalise things, that's fine, but this is not the
way to do it.
2024-03-27 Segher Boessenkool <segher@kernel.crashing.org>
The following avoids re-walking and re-combining the instructions
between i2 and i3 when the pattern of i2 doesn't change.
PR rtl-optimization/101523
* combine.cc (try_combine): Don't do a 2-insn combination if
it does not in fact change I2.
* 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 | 11 +++++++++++
1 file changed, 11 insertions(+)
gcc/combine.cc | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/gcc/combine.cc b/gcc/combine.cc
index a4479f8d836..745391016d0 100644
index a4479f8d836..ff25752cac4 100644
--- a/gcc/combine.cc
+++ b/gcc/combine.cc
@@ -4186,6 +4186,17 @@ try_combine (rtx_insn *i3, rtx_insn *i2, rtx_insn *i1, rtx_insn *i0,
@@ -4186,6 +4186,10 @@ try_combine (rtx_insn *i3, rtx_insn *i2, rtx_insn *i1, rtx_insn *i0,
adjust_for_new_dest (i3);
}
+ /* If I2 didn't change, this is not a combination (but a simplification or
+ canonicalisation with context), which should not be done here. Doing
+ it here explodes the algorithm. Don't. */
+ bool i2_unchanged = false;
+ if (rtx_equal_p (newi2pat, PATTERN (i2)))
+ {
+ if (dump_file)
+ fprintf (dump_file, "i2 didn't change, not doing this\n");
+ undo_all ();
+ return 0;
+ }
+ 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;
--
2.35.3

View File

@ -1,5 +1,5 @@
-------------------------------------------------------------------
Thu Mar 28 06:55:18 UTC 2024 - Richard Biener <rguenther@suse.com>
Thu Apr 4 07:43:17 UTC 2024 - Richard Biener <rguenther@suse.com>
- Add gcc13-pr101523.patch to avoid combine spending too much
compile-time and memory doing nothing on s390x. [boo#1188441]