Re: [PATCH]middle-end Guard value_replacement and store_elim from seeing diamonds.

2023-03-30 Thread Andrew Pinski via Gcc-patches
On Fri, Aug 5, 2022 at 6:16 AM Tamar Christina via Gcc-patches
 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 ())
>   {
> phi = as_a  (gsi_stmt (gsi));
>
>
>
>
> --


Re: [PATCH]middle-end Guard value_replacement and store_elim from seeing diamonds.

2022-08-05 Thread Richard Biener via Gcc-patches
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 ())
> {
>   phi = as_a  (gsi_stmt (gsi));
> 
> 
> 
> 
> 

-- 
Richard Biener 
SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg,
Germany; GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman;
HRB 36809 (AG Nuernberg)


[PATCH]middle-end Guard value_replacement and store_elim from seeing diamonds.

2022-08-05 Thread Tamar Christina via Gcc-patches
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
--- 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 ())
  {
phi = as_a  (gsi_stmt (gsi));




-- 
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 ())
  {
phi = as_a  (gsi_stmt (gsi));