aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSegher Boessenkool <segher@kernel.crashing.org>2024-03-27 14:09:52 +0000
committerSegher Boessenkool <segher@kernel.crashing.org>2024-03-27 16:02:15 +0000
commit839bc42772ba7af66af3bd16efed4a69511312ae (patch)
treedac744cb78e3335c557c528110f16ddc936f02e1
parentdb41057a94fe6cd556b3beedc0f5088ea485f950 (diff)
downloadgcc-839bc42772ba7af66af3bd16efed4a69511312ae.zip
gcc-839bc42772ba7af66af3bd16efed4a69511312ae.tar.gz
gcc-839bc42772ba7af66af3bd16efed4a69511312ae.tar.bz2
combine: Don't combine if I2 does not change
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> PR rtl-optimization/101523 * combine.cc (try_combine): Don't do a 2-insn combination if it does not in fact change I2.
-rw-r--r--gcc/combine.cc11
1 files changed, 11 insertions, 0 deletions
diff --git a/gcc/combine.cc b/gcc/combine.cc
index a4479f8..7453910 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,
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. */
+ 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;
+ }
+
/* We now know that we can do this combination. Merge the insns and
update the status of registers and LOG_LINKS. */