public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] PHIOPT: Improve replace_phi_edge_with_variable's dce_ssa_names slightly
@ 2023-05-03 23:11 Andrew Pinski
  2023-05-04  9:39 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: Andrew Pinski @ 2023-05-03 23:11 UTC (permalink / raw)
  To: gcc-patches; +Cc: Andrew Pinski

When I added the dce_ssa_names argument, I didn't realize bitmap was a
pointer so I used the default argument value as auto_bitmap(). But
instead we could just use nullptr and check if it was a nullptr
before calling simple_dce_from_worklist.

OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.

gcc/ChangeLog:

	* tree-ssa-phiopt.cc (replace_phi_edge_with_variable): Change
	the default argument value for dce_ssa_names to nullptr.
	Check to make sure dce_ssa_names is a non-nullptr before
	calling simple_dce_from_worklist.
---
 gcc/tree-ssa-phiopt.cc | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc
index 37b98ef3c52..fbc1fd66607 100644
--- a/gcc/tree-ssa-phiopt.cc
+++ b/gcc/tree-ssa-phiopt.cc
@@ -89,7 +89,7 @@ single_non_singleton_phi_for_edges (gimple_seq seq, edge e0, edge e1)
 static void
 replace_phi_edge_with_variable (basic_block cond_block,
 				edge e, gphi *phi, tree new_tree,
-				bitmap dce_ssa_names = auto_bitmap())
+				bitmap dce_ssa_names = nullptr)
 {
   basic_block bb = gimple_bb (phi);
   gimple_stmt_iterator gsi;
@@ -164,7 +164,8 @@ replace_phi_edge_with_variable (basic_block cond_block,
 	gimple_cond_make_true (cond);
     }
 
-  simple_dce_from_worklist (dce_ssa_names);
+  if (dce_ssa_names)
+    simple_dce_from_worklist (dce_ssa_names);
 
   statistics_counter_event (cfun, "Replace PHI with variable", 1);
 
-- 
2.31.1


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

* Re: [PATCH] PHIOPT: Improve replace_phi_edge_with_variable's dce_ssa_names slightly
  2023-05-03 23:11 [PATCH] PHIOPT: Improve replace_phi_edge_with_variable's dce_ssa_names slightly Andrew Pinski
@ 2023-05-04  9:39 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2023-05-04  9:39 UTC (permalink / raw)
  To: Andrew Pinski; +Cc: gcc-patches

On Thu, May 4, 2023 at 1:11 AM Andrew Pinski via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> When I added the dce_ssa_names argument, I didn't realize bitmap was a
> pointer so I used the default argument value as auto_bitmap(). But
> instead we could just use nullptr and check if it was a nullptr
> before calling simple_dce_from_worklist.
>
> OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.

OK.

> gcc/ChangeLog:
>
>         * tree-ssa-phiopt.cc (replace_phi_edge_with_variable): Change
>         the default argument value for dce_ssa_names to nullptr.
>         Check to make sure dce_ssa_names is a non-nullptr before
>         calling simple_dce_from_worklist.
> ---
>  gcc/tree-ssa-phiopt.cc | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc
> index 37b98ef3c52..fbc1fd66607 100644
> --- a/gcc/tree-ssa-phiopt.cc
> +++ b/gcc/tree-ssa-phiopt.cc
> @@ -89,7 +89,7 @@ single_non_singleton_phi_for_edges (gimple_seq seq, edge e0, edge e1)
>  static void
>  replace_phi_edge_with_variable (basic_block cond_block,
>                                 edge e, gphi *phi, tree new_tree,
> -                               bitmap dce_ssa_names = auto_bitmap())
> +                               bitmap dce_ssa_names = nullptr)
>  {
>    basic_block bb = gimple_bb (phi);
>    gimple_stmt_iterator gsi;
> @@ -164,7 +164,8 @@ replace_phi_edge_with_variable (basic_block cond_block,
>         gimple_cond_make_true (cond);
>      }
>
> -  simple_dce_from_worklist (dce_ssa_names);
> +  if (dce_ssa_names)
> +    simple_dce_from_worklist (dce_ssa_names);
>
>    statistics_counter_event (cfun, "Replace PHI with variable", 1);
>
> --
> 2.31.1
>

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

end of thread, other threads:[~2023-05-04  9:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-03 23:11 [PATCH] PHIOPT: Improve replace_phi_edge_with_variable's dce_ssa_names slightly Andrew Pinski
2023-05-04  9:39 ` 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).