]> git.ipfire.org Git - thirdparty/gcc.git/commit
cfgcleanup: Protect latches always [PR123417]
authorAndrew Pinski <andrew.pinski@oss.qualcomm.com>
Fri, 9 Jan 2026 10:02:01 +0000 (02:02 -0800)
committerAndrew Pinski <andrew.pinski@oss.qualcomm.com>
Sat, 10 Jan 2026 13:09:17 +0000 (05:09 -0800)
commit3ebe697f32197ec4a429fbf8dd9cce3155c0c9ba
tree1d3df406d3c8aee31835c3e8876cf4ccb9434c35
parent5079424ade2deddfa8d39a48a892f60679e4e32d
cfgcleanup: Protect latches always [PR123417]

So it turns out LOOPS_MAY_HAVE_MULTIPLE_LATCHES is set in places
along compiling. Setting it only means there might be multiple
latches currently. It does not mean let's go in an delete them
all; which is what remove_forwarder_block does currently. This
was happening before my set of patches too but since it was
only happening in merge_phi pass, latches were not cleared away
al of the time and then recreated.

This solves the problem by protecting latches all of the time
instead of depedent on LOOPS_MAY_HAVE_MULTIPLE_LATCHES not being set.

vect-uncounted_7.c needs to be xfailed here because we no longer
vectorize the code. Note the IR between GCC 15 and after this patch
is the same so I think this was just a case were the testcase
was added after the remove forwarder changes and should not have
vectorized (or vectorize differently).

Bootstrapped and tested on x86_64-linux-gnu.

PR tree-optimization/123417
gcc/ChangeLog:

* tree-cfgcleanup.cc (maybe_remove_forwarder_block): Always
protect latches.

gcc/testsuite/ChangeLog:

* gcc.dg/vect/vect-uncounted_7.c: xfail vect test.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
gcc/testsuite/gcc.dg/vect/vect-uncounted_7.c
gcc/tree-cfgcleanup.cc