https://gcc.gnu.org/g:4143a49e0ddfe269f390057a9a21d1fc396e6db1
commit r16-5249-g4143a49e0ddfe269f390057a9a21d1fc396e6db1 Author: Andrew Pinski <[email protected]> Date: Sun Nov 9 13:56:12 2025 -0800 cfglceanup: Remove check for infinite loop in remove_forwarder_block/remove_forwarder_block_with_phi Since removing the worklist for both mergephi and cfglceanup (r0-80545-g672987e82f472b), these two functions are now called right after tree_forwarder_block_p so there is no reason to the extra check for infinite loop nor the current loop on the headers check as it is already handled in tree_forwarder_block_p. Bootstrapped and tested on x86_64-linux-gnu. gcc/ChangeLog: * tree-cfgcleanup.cc (remove_forwarder_block): Remove check for infinite loop. (remove_forwarder_block_with_phi): Likewise. Also remove check for loop header. Signed-off-by: Andrew Pinski <[email protected]> Diff: --- gcc/tree-cfgcleanup.cc | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/gcc/tree-cfgcleanup.cc b/gcc/tree-cfgcleanup.cc index 2e613df6855a..6f97c7e41ad2 100644 --- a/gcc/tree-cfgcleanup.cc +++ b/gcc/tree-cfgcleanup.cc @@ -582,12 +582,6 @@ remove_forwarder_block (basic_block bb) edge_iterator ei; gimple_stmt_iterator gsi, gsi_to; - /* We check for infinite loops already in tree_forwarder_block_p. - However it may happen that the infinite loop is created - afterwards due to removal of forwarders. */ - if (dest == bb) - return false; - /* If the destination block consists of a nonlocal label or is a EH landing pad, do not merge it. */ stmt = first_stmt (dest); @@ -1262,17 +1256,6 @@ remove_forwarder_block_with_phi (basic_block bb) gimple *label; basic_block dombb, domdest, dom; - /* We check for infinite loops already in tree_forwarder_block_p. - However it may happen that the infinite loop is created - afterwards due to removal of forwarders. */ - if (dest == bb) - return false; - - /* Removal of forwarders may expose new natural loops and thus - a block may turn into a loop header. */ - if (current_loops && bb_loop_header_p (bb)) - return false; - /* If the destination block consists of a nonlocal label, do not merge it. */ label = first_stmt (dest);
