[Bug tree-optimization/122734] [15/16 Regression] ch gets confused with some extra if (a) __builtin_unreachable
cvs-commit at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sat Dec 13 10:33:09 GMT 2025
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122734
--- Comment #8 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Andrew Pinski <pinskia@gcc.gnu.org>:
https://gcc.gnu.org/g:b5c64db0a49d4653418457a520648c4305e01e75
commit r16-6104-gb5c64db0a49d4653418457a520648c4305e01e75
Author: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
Date: Tue Nov 18 23:02:36 2025 -0800
ch: Improve copy header when the bbs are predicated as non-executed
[PR122734]
This is version based on
https://gcc.gnu.org/pipermail/gcc-patches/2025-November/701533.html
review. Though the only thing is we still need an extra check for the edge
probability
like it is done in single_likely_exit because probabilities are still not
being tracked
correctly it seems.
I also added copy-headers-12.c which we fail by duplicating too much. But I
think that is ok,
as this pattern of being the "correct" part of the loop header leading to a
noreturn function does not happen that often and when it does the header
would have had a
statically figured out conditional which is already being checked.
Bootstrapped and tested on x86_64-linux-gnu.
PR tree-optimization/122734
gcc/ChangeLog:
* tree-ssa-loop-ch.cc (should_duplicate_loop_header_p): Add new
argument,
canbe_neverexecuted. When canbe_neverexecuted is true, return if a
loop
exit is "never executed" like we are doing an invariant
conditional.
(ch_base::copy_headers): Update call to
should_duplicate_loop_header_p.
gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/20030711-1.c: Update.
* gcc.dg/tree-ssa/copy-headers-10.c: New test.
* gcc.dg/tree-ssa/copy-headers-11.c: New test.
* gcc.dg/tree-ssa/copy-headers-12.c: New test.
Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
More information about the Gcc-bugs
mailing list