diff mbox series

[1/6] PHIOPT: Move check on diamond bb to tree_ssa_phiopt_worker from minmax_replacement

Message ID 20230422220921.452264-2-apinski@marvell.com
State New
Headers show
Series Improve PHIOPT match and simplify for diamond shaped bbs | expand

Commit Message

Andrew Pinski April 22, 2023, 10:09 p.m. UTC
This moves the check to make sure on the diamond shaped form bbs that
the the two middle bbs are only for that diamond shaped form earlier
in the shared code.
Also remove the redundant check for single_succ_p since that was already
done before hand.
The next patch will simplify the code even further and remove redundant
checks.

gcc/ChangeLog:

	* tree-ssa-phiopt.cc (tree_ssa_phiopt_worker): Move the
	diamond form check from ...
	(minmax_replacement): Here.
---
 gcc/tree-ssa-phiopt.cc | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

Comments

Richard Biener April 24, 2023, 12:01 p.m. UTC | #1
On Sun, Apr 23, 2023 at 12:11 AM Andrew Pinski via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> This moves the check to make sure on the diamond shaped form bbs that
> the the two middle bbs are only for that diamond shaped form earlier
> in the shared code.
> Also remove the redundant check for single_succ_p since that was already
> done before hand.
> The next patch will simplify the code even further and remove redundant
> checks.

OK.

> gcc/ChangeLog:
>
>         * tree-ssa-phiopt.cc (tree_ssa_phiopt_worker): Move the
>         diamond form check from ...
>         (minmax_replacement): Here.
> ---
>  gcc/tree-ssa-phiopt.cc | 14 ++++++++------
>  1 file changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc
> index d886c88215b..296ba646e62 100644
> --- a/gcc/tree-ssa-phiopt.cc
> +++ b/gcc/tree-ssa-phiopt.cc
> @@ -220,6 +220,14 @@ tree_ssa_phiopt_worker (bool do_store_elim, bool do_hoist_loads, bool early_p)
>           continue;
>         }
>
> +      if (diamond_p)
> +       {
> +         if (!single_pred_p (bb1)
> +             || !single_pred_p (bb2)
> +             || !single_succ_p (bb2))
> +           continue;
> +       }
> +
>        if (do_store_elim && !diamond_p)
>         {
>           /* Also make sure that bb1 only have one predecessor and that it
> @@ -2032,12 +2040,6 @@ minmax_replacement (basic_block cond_bb, basic_block middle_bb, basic_block alt_
>        tree alt_lhs, alt_op0, alt_op1;
>        bool invert = false;
>
> -      if (!single_pred_p (middle_bb)
> -         || !single_pred_p (alt_middle_bb)
> -         || !single_succ_p (middle_bb)
> -         || !single_succ_p (alt_middle_bb))
> -       return false;
> -
>        /* When THREEWAY_P then e1 will point to the edge of the final transition
>          from middle-bb to end.  */
>        if (true_edge == e0)
> --
> 2.39.1
>
diff mbox series

Patch

diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc
index d886c88215b..296ba646e62 100644
--- a/gcc/tree-ssa-phiopt.cc
+++ b/gcc/tree-ssa-phiopt.cc
@@ -220,6 +220,14 @@  tree_ssa_phiopt_worker (bool do_store_elim, bool do_hoist_loads, bool early_p)
 	  continue;
 	}
 
+      if (diamond_p)
+	{
+	  if (!single_pred_p (bb1)
+	      || !single_pred_p (bb2)
+	      || !single_succ_p (bb2))
+	    continue;
+	}
+
       if (do_store_elim && !diamond_p)
 	{
 	  /* Also make sure that bb1 only have one predecessor and that it
@@ -2032,12 +2040,6 @@  minmax_replacement (basic_block cond_bb, basic_block middle_bb, basic_block alt_
       tree alt_lhs, alt_op0, alt_op1;
       bool invert = false;
 
-      if (!single_pred_p (middle_bb)
-	  || !single_pred_p (alt_middle_bb)
-	  || !single_succ_p (middle_bb)
-	  || !single_succ_p (alt_middle_bb))
-	return false;
-
       /* When THREEWAY_P then e1 will point to the edge of the final transition
 	 from middle-bb to end.  */
       if (true_edge == e0)