]> git.ipfire.org Git - thirdparty/gcc.git/commit
Fix tree-ssa/update-cunroll.c
authorJan Hubicka <jh@suse.cz>
Sat, 8 Jul 2023 15:38:09 +0000 (17:38 +0200)
committerJan Hubicka <jh@suse.cz>
Sat, 8 Jul 2023 15:38:09 +0000 (17:38 +0200)
commit15bbf1826a01f5beb2d7c0f74d6270bbc94ece91
tree91f414cf14ee54effb9c9f1643ce1c87ab26b50f
parentb1079fc88f082d3c5b583c8822c08c5647810259
Fix tree-ssa/update-cunroll.c

In this testcase the profile is misupdated before loop has two exits.
The first exit is one eliminated by complete unrolling while second exit remains.
We remove first exit but forget about fact that the source BB of other exit will
then have higher frequency making other exit more likely.

This patch fixes that in duplicate_loop_body_to_header_edge.
While looking into resulting profiles I also noticed that in some cases
scale_loop_profile may drop probabilities to 0 incorrectly either when
trying to update exit from nested loop (which has similar problem) or when the profile
was inconsistent as described in coment bellow.

gcc/ChangeLog:

PR middle-end/110590
* cfgloopmanip.cc (scale_loop_profile): Avoid scaling exits within
inner loops and be more careful about inconsistent profiles.
(duplicate_loop_body_to_header_edge): Fix profile update when eliminated
exit is followed by other exit.

gcc/testsuite/ChangeLog:

PR middle-end/110590
* gcc.dg/tree-prof/update-cunroll-2.c: Remove xfail.
* gcc.dg/tree-ssa/update-cunroll.c: Likewise.
gcc/cfgloopmanip.cc
gcc/testsuite/gcc.dg/tree-prof/update-cunroll-2.c
gcc/testsuite/gcc.dg/tree-ssa/update-cunroll.c