]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
mergephi: Add stats
authorAndrew Pinski <andrew.pinski@oss.qualcomm.com>
Sat, 15 Nov 2025 22:44:21 +0000 (14:44 -0800)
committerAndrew Pinski <andrew.pinski@oss.qualcomm.com>
Mon, 17 Nov 2025 19:06:44 +0000 (11:06 -0800)
This just adds a simple stats recording. Main reason is that I want to find
out if we can remove one of the mergephi now.

Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

* tree-cfgcleanup.cc (pass_merge_phi::execute): Add stats for the removed
blocks.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
gcc/tree-cfgcleanup.cc

index a78b711d82c31e75dbbef7ff23c79731ef3926be..9aeb4f3fc99e1c6f610cb60a62b02cc3630b268f 100644 (file)
@@ -1372,10 +1372,10 @@ public:
 unsigned int
 pass_merge_phi::execute (function *fun)
 {
+  int forwarder_removed = 0;
   calculate_dominance_info (CDI_DOMINATORS);
 
   /* Find all PHI nodes that we may be able to merge.  */
-  bool changed = false;
   unsigned n = last_basic_block_for_fn (fun);
   for (unsigned i = NUM_FIXED_BLOCKS; i < n; i++)
     {
@@ -1386,15 +1386,17 @@ pass_merge_phi::execute (function *fun)
       /* Look for a forwarder block with PHI nodes.  */
       if (tree_forwarder_block_p (bb)
          && remove_forwarder_block (bb, true))
-       changed = true;
+       forwarder_removed++;
     }
 
   /* Removing forwarder blocks can cause formerly irreducible loops
      to become reducible if we merged two entry blocks.  */
-  if (changed
+  if (forwarder_removed != 0
       && current_loops)
     loops_state_set (LOOPS_NEED_FIXUP);
 
+  statistics_counter_event (fun, "Forwarder blocks removed",
+                           forwarder_removed);
   return 0;
 }