]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
phiopt: Use mark_lhs_in_seq_for_dce instead of doing it inline
authorAndrew Pinski <quic_apinski@quicinc.com>
Sun, 18 May 2025 00:21:39 +0000 (17:21 -0700)
committerAndrew Pinski <quic_apinski@quicinc.com>
Sun, 18 May 2025 16:37:02 +0000 (09:37 -0700)
Right now phiopt has the same code as mark_lhs_in_seq_for_dce
inlined into match_simplify_replacement. Instead let's use the
function in gimple-fold that does the same thing.

Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

* gimple-fold.cc (mark_lhs_in_seq_for_dce): Make
non-static.
* gimple-fold.h (mark_lhs_in_seq_for_dce): Declare.
* tree-ssa-phiopt.cc (match_simplify_replacement): Use
mark_lhs_in_seq_for_dce instead of manually looping.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
gcc/gimple-fold.cc
gcc/gimple-fold.h
gcc/tree-ssa-phiopt.cc

index b74fb8bb50cbf341dfb30807842a8d40176ecf3d..0f437616d770e13db355e043ffd457d21cb720c5 100644 (file)
@@ -6020,7 +6020,7 @@ has_use_on_stmt (tree name, gimple *stmt)
 
 /* Add the lhs of each statement of SEQ to DCE_WORKLIST. */
 
-static void
+void
 mark_lhs_in_seq_for_dce (bitmap dce_worklist, gimple_seq seq)
 {
   if (!dce_worklist)
index afecbb8ceefce247c4eaaa532b91129bc6586cbc..8b1e246b0c07b06594f7df2738b251a4683b8b22 100644 (file)
@@ -264,6 +264,7 @@ gimple_build_round_up (gimple_seq *seq, tree type, tree old_size,
 
 extern bool gimple_stmt_nonnegative_warnv_p (gimple *, bool *, int = 0);
 extern bool gimple_stmt_integer_valued_real_p (gimple *, int = 0);
+extern void mark_lhs_in_seq_for_dce (bitmap, gimple_seq);
 
 /* In gimple-match.cc.  */
 extern tree gimple_simplify (enum tree_code, tree, tree,
index 9724040fc3d20ba68a7e0b4a9316a08ef30f3272..8c5908e5bff9e3c4d0af176890fd8c500b158b58 100644 (file)
@@ -1001,16 +1001,9 @@ match_simplify_replacement (basic_block cond_bb, basic_block middle_bb,
   if (seq)
     {
       // Mark the lhs of the new statements maybe for dce
-      gimple_stmt_iterator gsi1 = gsi_start (seq);
-      for (; !gsi_end_p (gsi1); gsi_next (&gsi1))
-       {
-         gimple *stmt = gsi_stmt (gsi1);
-         tree name = gimple_get_lhs (stmt);
-         if (name && TREE_CODE (name) == SSA_NAME)
-           bitmap_set_bit (exprs_maybe_dce, SSA_NAME_VERSION (name));
-       }
-    gsi_insert_seq_before (&gsi, seq, GSI_CONTINUE_LINKING);
-  }
+      mark_lhs_in_seq_for_dce (exprs_maybe_dce, seq);
+      gsi_insert_seq_before (&gsi, seq, GSI_CONTINUE_LINKING);
+    }
 
   /* If there was a statement to move, move it to right before
      the original conditional.  */