https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122493
--- Comment #16 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The trunk branch has been updated by Andrew Pinski <[email protected]>: https://gcc.gnu.org/g:1d8e2d51e5c5cbdb6ad6f455a050af869103dad4 commit r16-5258-g1d8e2d51e5c5cbdb6ad6f455a050af869103dad4 Author: Andrew Pinski <[email protected]> Date: Tue Nov 11 11:29:38 2025 -0800 cfgcleanup: Support merging forwarder blocks with phis [PR122493] This adds support for merging forwarder blocks with phis in cleanupcfg. This patch might seem small but that is because the previous patches were done to build up to make it easier to add this support. There is still one more patch to merge remove_forwarder_block and remove_forwarder_block_with_phi since remove_forwarder_block_with_phi supports splitting an edge which is not supported as an option in remove_forwarder_block. The splitting edge option should not be enabled for cfgcleanup but only for mergephi. Note r8-338-ge7d70c6c3bccb2 added always creating a preheader for loops so we should protect them if we have a phi node as it goes back and forth here. And both the gimple and RTL loop code likes to have this preheader in the case of having the same constant value being starting of the loop. explaination on testcase changes gcc.target/i386/pr121062-1.c needed a small change because there is a basic block which is not duplicated so only one `movq reg, -1` is there instead of 2. uninit-pred-7_a.c is xfailed and filed as PR122660, some analysis in the PR already of the difference now. uninit-pred-5.C was actually a false positive because when m_best_candidate is non-NULL, m_best_candidate_len is always initialized. The log message on the testcase is wrong if you manually fall the path you can notice that. With an extra jump threading after the merging of some bbs, the false positive is now no longer happening. So change the dg-warning to dg-bogus. ssa-dom-thread-7.c now jump threads 12 times in thread2 instead of 8 Bootstrapped and tested on x86_64-linux-gnu. PR tree-optimization/122493 gcc/ChangeLog: * tree-cfgcleanup.cc (tree_forwarder_block_p): Change bool argument to a must have phi and allow phis if it is false. (remove_forwarder_block): Add support for merging of forwarder blocks with phis. gcc/testsuite/ChangeLog: * gcc.target/i386/pr121062-1.c: Update count. * gcc.dg/uninit-pred-7_a.c: xfail line 23. * g++.dg/uninit-pred-5.C: Change dg-warning to dg-bogus. * gcc.dg/tree-ssa/ssa-dom-thread-7.c: Update count of jump thread. Signed-off-by: Andrew Pinski <[email protected]>
