https://gcc.gnu.org/g:c0be0298a9553c13af642f45628a15d833473657

commit r16-1194-gc0be0298a9553c13af642f45628a15d833473657
Author: Andrew Pinski <quic_apin...@quicinc.com>
Date:   Fri May 30 22:30:01 2025 -0700

    CCP: Manually rename the virtual mem op when inserting clobbers
    
    Right now the only place where CCP needs to have the virtual op renamed is
    after inserting clobbers which come right before __builtin_stack_restore.
    So let's manually do the correct thing so we can remove the TODO_update_ssa 
todo.
    
    gcc/ChangeLog:
    
            * tree-ssa-ccp.cc (insert_clobber_before_stack_restore): Update the 
virtual
            op on the inserted clobber and the stack restore function.
            (do_ssa_ccp): Don't add TODO_update_ssa to the todo.
    
    Signed-off-by: Andrew Pinski <quic_apin...@quicinc.com>

Diff:
---
 gcc/tree-ssa-ccp.cc | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/gcc/tree-ssa-ccp.cc b/gcc/tree-ssa-ccp.cc
index 3e0c75cf2be8..13cd81d95672 100644
--- a/gcc/tree-ssa-ccp.cc
+++ b/gcc/tree-ssa-ccp.cc
@@ -2567,7 +2567,12 @@ insert_clobber_before_stack_restore (tree saved_val, 
tree var,
       {
        clobber = build_clobber (TREE_TYPE (var), CLOBBER_STORAGE_END);
        clobber_stmt = gimple_build_assign (var, clobber);
-
+       /* Manually update the vdef/vuse here. */
+       gimple_set_vuse (clobber_stmt, gimple_vuse (stmt));
+       gimple_set_vdef (clobber_stmt, make_ssa_name (gimple_vop (cfun)));
+       gimple_set_vuse (stmt, gimple_vdef (clobber_stmt));
+       SSA_NAME_DEF_STMT (gimple_vdef (clobber_stmt)) = clobber_stmt;
+       update_stmt (stmt);
        i = gsi_for_stmt (stmt);
        gsi_insert_before (&i, clobber_stmt, GSI_SAME_STMT);
       }
@@ -3020,7 +3025,7 @@ do_ssa_ccp (bool nonzero_p)
   ccp_propagate.ssa_propagate ();
   if (ccp_finalize (nonzero_p || flag_ipa_bit_cp))
     {
-      todo = (TODO_cleanup_cfg | TODO_update_ssa);
+      todo = TODO_cleanup_cfg;
 
       /* ccp_finalize does not preserve loop-closed ssa.  */
       loops_state_clear (LOOP_CLOSED_SSA);

Reply via email to