diff mbox series

middle-end Guard value_replacement and store_elim from seeing diamonds.

Message ID patch-16124-tamar@arm.com
State New
Headers show
Series middle-end Guard value_replacement and store_elim from seeing diamonds. | expand

Commit Message

Tamar Christina Aug. 5, 2022, 1:15 p.m. UTC
Hi All,

This excludes value_replacement and store_elim from diamonds as they don't
handle the form properly.

Bootstrapped Regtested on aarch64-none-linux-gnu, x86_64-pc-linux-gnu
and no issues.

Ok for master?

Thanks,
Tamar

gcc/ChangeLog:

	PR middle-end/106534
	* tree-ssa-phiopt.cc (tree_ssa_phiopt_worker): Guard the
	value_replacement and store_elim from diamonds.

--- inline copy of patch -- 
diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc
index bdbf52916b0f88ee4f475e1fa306046d61f13d53..1e002c608591836ffb001724b3f469a8d042ae5e 100644




--
diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc
index bdbf52916b0f88ee4f475e1fa306046d61f13d53..1e002c608591836ffb001724b3f469a8d042ae5e 100644
--- a/gcc/tree-ssa-phiopt.cc
+++ b/gcc/tree-ssa-phiopt.cc
@@ -283,7 +283,7 @@ tree_ssa_phiopt_worker (bool do_store_elim, bool do_hoist_loads, bool early_p)
 	  || (e1->flags & EDGE_FALLTHRU) == 0)
         continue;
 
-      if (do_store_elim)
+      if (do_store_elim && !diamond_p)
 	{
 	  /* Also make sure that bb1 only have one predecessor and that it
 	     is bb.  */
@@ -310,7 +310,7 @@ tree_ssa_phiopt_worker (bool do_store_elim, bool do_hoist_loads, bool early_p)
 
 	  /* Value replacement can work with more than one PHI
 	     so try that first. */
-	  if (!early_p)
+	  if (!early_p && !diamond_p)
 	    for (gsi = gsi_start (phis); !gsi_end_p (gsi); gsi_next (&gsi))
 	      {
 		phi = as_a <gphi *> (gsi_stmt (gsi));

Comments

Richard Biener Aug. 5, 2022, 1:47 p.m. UTC | #1
On Fri, 5 Aug 2022, Tamar Christina wrote:

> Hi All,
> 
> This excludes value_replacement and store_elim from diamonds as they don't
> handle the form properly.
> 
> Bootstrapped Regtested on aarch64-none-linux-gnu, x86_64-pc-linux-gnu
> and no issues.
> 
> Ok for master?

OK

> Thanks,
> Tamar
> 
> gcc/ChangeLog:
> 
> 	PR middle-end/106534
> 	* tree-ssa-phiopt.cc (tree_ssa_phiopt_worker): Guard the
> 	value_replacement and store_elim from diamonds.
> 
> --- inline copy of patch -- 
> diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc
> index bdbf52916b0f88ee4f475e1fa306046d61f13d53..1e002c608591836ffb001724b3f469a8d042ae5e 100644
> --- a/gcc/tree-ssa-phiopt.cc
> +++ b/gcc/tree-ssa-phiopt.cc
> @@ -283,7 +283,7 @@ tree_ssa_phiopt_worker (bool do_store_elim, bool do_hoist_loads, bool early_p)
>  	  || (e1->flags & EDGE_FALLTHRU) == 0)
>          continue;
>  
> -      if (do_store_elim)
> +      if (do_store_elim && !diamond_p)
>  	{
>  	  /* Also make sure that bb1 only have one predecessor and that it
>  	     is bb.  */
> @@ -310,7 +310,7 @@ tree_ssa_phiopt_worker (bool do_store_elim, bool do_hoist_loads, bool early_p)
>  
>  	  /* Value replacement can work with more than one PHI
>  	     so try that first. */
> -	  if (!early_p)
> +	  if (!early_p && !diamond_p)
>  	    for (gsi = gsi_start (phis); !gsi_end_p (gsi); gsi_next (&gsi))
>  	      {
>  		phi = as_a <gphi *> (gsi_stmt (gsi));
> 
> 
> 
> 
>
Andrew Pinski March 30, 2023, 10:58 p.m. UTC | #2
On Fri, Aug 5, 2022 at 6:16 AM Tamar Christina via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> Hi All,
>
> This excludes value_replacement and store_elim from diamonds as they don't
> handle the form properly.
>
> Bootstrapped Regtested on aarch64-none-linux-gnu, x86_64-pc-linux-gnu
> and no issues.
>
> Ok for master?

I just noticed this changes the behavior of the store elimination pass
to also act like phi-opt if bb layout was a diamond.
I will be submitting a patch for GCC 14 to revert back that behavior
with some refactoring I am doing to improve the readability of the
code.

Thanks,
Andrew Pinski

>
> Thanks,
> Tamar
>
> gcc/ChangeLog:
>
>         PR middle-end/106534
>         * tree-ssa-phiopt.cc (tree_ssa_phiopt_worker): Guard the
>         value_replacement and store_elim from diamonds.
>
> --- inline copy of patch --
> diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc
> index bdbf52916b0f88ee4f475e1fa306046d61f13d53..1e002c608591836ffb001724b3f469a8d042ae5e 100644
> --- a/gcc/tree-ssa-phiopt.cc
> +++ b/gcc/tree-ssa-phiopt.cc
> @@ -283,7 +283,7 @@ tree_ssa_phiopt_worker (bool do_store_elim, bool do_hoist_loads, bool early_p)
>           || (e1->flags & EDGE_FALLTHRU) == 0)
>          continue;
>
> -      if (do_store_elim)
> +      if (do_store_elim && !diamond_p)
>         {
>           /* Also make sure that bb1 only have one predecessor and that it
>              is bb.  */
> @@ -310,7 +310,7 @@ tree_ssa_phiopt_worker (bool do_store_elim, bool do_hoist_loads, bool early_p)
>
>           /* Value replacement can work with more than one PHI
>              so try that first. */
> -         if (!early_p)
> +         if (!early_p && !diamond_p)
>             for (gsi = gsi_start (phis); !gsi_end_p (gsi); gsi_next (&gsi))
>               {
>                 phi = as_a <gphi *> (gsi_stmt (gsi));
>
>
>
>
> --
diff mbox series

Patch

--- a/gcc/tree-ssa-phiopt.cc
+++ b/gcc/tree-ssa-phiopt.cc
@@ -283,7 +283,7 @@  tree_ssa_phiopt_worker (bool do_store_elim, bool do_hoist_loads, bool early_p)
 	  || (e1->flags & EDGE_FALLTHRU) == 0)
         continue;
 
-      if (do_store_elim)
+      if (do_store_elim && !diamond_p)
 	{
 	  /* Also make sure that bb1 only have one predecessor and that it
 	     is bb.  */
@@ -310,7 +310,7 @@  tree_ssa_phiopt_worker (bool do_store_elim, bool do_hoist_loads, bool early_p)
 
 	  /* Value replacement can work with more than one PHI
 	     so try that first. */
-	  if (!early_p)
+	  if (!early_p && !diamond_p)
 	    for (gsi = gsi_start (phis); !gsi_end_p (gsi); gsi_next (&gsi))
 	      {
 		phi = as_a <gphi *> (gsi_stmt (gsi));