]> git.feebdaed.xyz Git - 0xmirror/gcc.git/commit
ch: Fix detection of non-executed loop exit
authorAndrew Pinski <andrew.pinski@oss.qualcomm.com>
Mon, 15 Dec 2025 20:36:44 +0000 (12:36 -0800)
committerAndrew Pinski <andrew.pinski@oss.qualcomm.com>
Thu, 18 Dec 2025 02:53:53 +0000 (18:53 -0800)
commit135fe58ec9a989fc301d762547325fd90ea37397
treee189f4832211caad42b7f027a2aea84780ccb900
parentb2b5ccb0a2450a812526bdde72545f9c85fce473
ch: Fix detection of non-executed loop exit

After r16-6104-gb5c64db0a49d46, we try to duplicate bb's
that contain loop exit that have "never exit" but we check
against the propability of the exit to very_unlikely. If we
have PGO, then a loop exit might be very unlikely to be taken
if we interate the loop more than 2000 times.
The problem is the check for very_unlikely is just wrong. It should
just be never. So let's remove that.

Also adds a testcase for __builtin_abort instead of __builtin_unreachable
since there are slightly different pathes to get the probilities.

Bootstrapped and tested on x86_64-linux-gnu.

PR tree-optimization/122734
gcc/ChangeLog:

* tree-ssa-loop-ch.cc (should_duplicate_loop_header_p): Remove
check on very_unlikely probability.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/copy-headers-13.c: New test.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
gcc/testsuite/gcc.dg/tree-ssa/copy-headers-13.c [new file with mode: 0644]
gcc/tree-ssa-loop-ch.cc