public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Add stats to simple_dce_from_worklist
@ 2023-05-02 23:14 Andrew Pinski
  2023-05-03  6:16 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: Andrew Pinski @ 2023-05-02 23:14 UTC (permalink / raw)
  To: gcc-patches; +Cc: Andrew Pinski

While looking to move substitute_and_fold_engine
over to use simple_dce_from_worklist, I noticed
that we don't record the stats of the removed stmts/phis.
So this does that.

OK? Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

	* tree-ssa-dce.cc (simple_dce_from_worklist): Record
	stats on removed number of statements and phis.
---
 gcc/tree-ssa-dce.cc | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/gcc/tree-ssa-dce.cc b/gcc/tree-ssa-dce.cc
index 1fd88e8ee37..86a33e1a40d 100644
--- a/gcc/tree-ssa-dce.cc
+++ b/gcc/tree-ssa-dce.cc
@@ -2099,6 +2099,8 @@ make_pass_cd_dce (gcc::context *ctxt)
 void
 simple_dce_from_worklist (bitmap worklist)
 {
+  long phiremoved = 0;
+  long stmtremoved = 0;
   while (! bitmap_empty_p (worklist))
     {
       /* Pop item.  */
@@ -2144,12 +2146,20 @@ simple_dce_from_worklist (bitmap worklist)
 	}
       gimple_stmt_iterator gsi = gsi_for_stmt (t);
       if (gimple_code (t) == GIMPLE_PHI)
-	remove_phi_node (&gsi, true);
+	{
+	  remove_phi_node (&gsi, true);
+	  phiremoved++;
+	}
       else
 	{
 	  unlink_stmt_vdef (t);
 	  gsi_remove (&gsi, true);
 	  release_defs (t);
+	  stmtremoved++;
 	}
     }
+  statistics_counter_event (cfun, "PHIs removed",
+			    phiremoved);
+  statistics_counter_event (cfun, "Statements removed",
+			    stmtremoved);
 }
-- 
2.39.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Add stats to simple_dce_from_worklist
  2023-05-02 23:14 [PATCH] Add stats to simple_dce_from_worklist Andrew Pinski
@ 2023-05-03  6:16 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2023-05-03  6:16 UTC (permalink / raw)
  To: Andrew Pinski; +Cc: gcc-patches

On Wed, May 3, 2023 at 1:15 AM Andrew Pinski via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> While looking to move substitute_and_fold_engine
> over to use simple_dce_from_worklist, I noticed
> that we don't record the stats of the removed stmts/phis.
> So this does that.
>
> OK? Bootstrapped and tested on x86_64-linux-gnu.
>
> gcc/ChangeLog:
>
>         * tree-ssa-dce.cc (simple_dce_from_worklist): Record
>         stats on removed number of statements and phis.
> ---
>  gcc/tree-ssa-dce.cc | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/gcc/tree-ssa-dce.cc b/gcc/tree-ssa-dce.cc
> index 1fd88e8ee37..86a33e1a40d 100644
> --- a/gcc/tree-ssa-dce.cc
> +++ b/gcc/tree-ssa-dce.cc
> @@ -2099,6 +2099,8 @@ make_pass_cd_dce (gcc::context *ctxt)
>  void
>  simple_dce_from_worklist (bitmap worklist)
>  {
> +  long phiremoved = 0;
> +  long stmtremoved = 0;

The statistics API takes an 'int', OK with changing these accordingly.

>    while (! bitmap_empty_p (worklist))
>      {
>        /* Pop item.  */
> @@ -2144,12 +2146,20 @@ simple_dce_from_worklist (bitmap worklist)
>         }
>        gimple_stmt_iterator gsi = gsi_for_stmt (t);
>        if (gimple_code (t) == GIMPLE_PHI)
> -       remove_phi_node (&gsi, true);
> +       {
> +         remove_phi_node (&gsi, true);
> +         phiremoved++;
> +       }
>        else
>         {
>           unlink_stmt_vdef (t);
>           gsi_remove (&gsi, true);
>           release_defs (t);
> +         stmtremoved++;
>         }
>      }
> +  statistics_counter_event (cfun, "PHIs removed",
> +                           phiremoved);
> +  statistics_counter_event (cfun, "Statements removed",
> +                           stmtremoved);
>  }
> --
> 2.39.1
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-05-03  6:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-02 23:14 [PATCH] Add stats to simple_dce_from_worklist Andrew Pinski
2023-05-03  6:16 ` Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).