https://gcc.gnu.org/g:94d8ce172848b39de198eb7f6e07ccd3685ef66e

commit r16-6107-g94d8ce172848b39de198eb7f6e07ccd3685ef66e
Author: Andrew Pinski <[email protected]>
Date:   Sat Dec 13 01:23:13 2025 -0800

    final_cleanupcfg: Make sure TODO_cleanup_cfg is unset
    
    While I was looking into the code generation of PR 122727,
    I noticed that TODO_cleanup_cfg could be set from the call to
    execute_fixup_cfg even though cleanupcfg did nothing afterwards.
    This means the forwarder blocks that were just created with
    make_forwarders_with_degenerate_phis are being removed.
    Instead of conditionally unsetting TODO_cleanup_cfg,
    unconditionally unset TODO_cleanup_cfg after the call
    to make_forwarders_with_degenerate_phis. Since we already
    did the cleanup (maybe twice).
    
    Bootstrapped and tested on x86_64-linux-gnu.
    
            PR tree-optimization/46555
    gcc/ChangeLog:
    
            * tree-cfgcleanup.cc (execute_cleanup_cfg_post_optimizing):
            Unconditionally set TODO_cleanup_cfg.
    
    Signed-off-by: Andrew Pinski <[email protected]>

Diff:
---
 gcc/tree-cfgcleanup.cc | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/gcc/tree-cfgcleanup.cc b/gcc/tree-cfgcleanup.cc
index 093fde93da6d..2521e6d09fd5 100644
--- a/gcc/tree-cfgcleanup.cc
+++ b/gcc/tree-cfgcleanup.cc
@@ -1409,10 +1409,7 @@ execute_cleanup_cfg_post_optimizing (void)
 {
   unsigned int todo = execute_fixup_cfg ();
   if (cleanup_tree_cfg ())
-    {
-      todo &= ~TODO_cleanup_cfg;
-      todo |= TODO_update_ssa;
-    }
+    todo |= TODO_update_ssa;
   maybe_remove_unreachable_handlers ();
   cleanup_dead_labels ();
   if (group_case_labels () && cleanup_tree_cfg ())
@@ -1423,6 +1420,11 @@ execute_cleanup_cfg_post_optimizing (void)
   if (optimize)
     make_forwarders_with_degenerate_phis (cfun);
 
+  /* Make sure todo does not have cleanup cfg as we don't want
+     remove the forwarder blocks we just created. cleanup cfg
+     has already happened.  */
+  todo &= ~TODO_cleanup_cfg;
+
   basic_block bb = single_succ (ENTRY_BLOCK_PTR_FOR_FN (cfun));
   gimple_stmt_iterator gsi = gsi_start_nondebug_after_labels_bb (bb);
   /* If the first (and only) bb and the only non debug

Reply via email to