public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Andrew Pinski <pinskia@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r14-170] PHIOPT: Improve readability of tree_ssa_phiopt_worker
Date: Sat, 22 Apr 2023 22:02:45 +0000 (GMT)	[thread overview]
Message-ID: <20230422220245.AD1353857739@sourceware.org> (raw)

https://gcc.gnu.org/g:e81b29a53948c413a480a3288f0f386372e2b4f7

commit r14-170-ge81b29a53948c413a480a3288f0f386372e2b4f7
Author: Andrew Pinski <apinski@marvell.com>
Date:   Wed Apr 19 14:42:45 2023 -0700

    PHIOPT: Improve readability of tree_ssa_phiopt_worker
    
    This small patch just changes around the code slightly to
    make it easier to understand that the cases were handling diamond
    shaped BB for both do_store_elim/do_hoist_loads.
    There is no effect on code output at all since all of the checks
    are the same still.
    
    OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.
    
    gcc/ChangeLog:
    
            * tree-ssa-phiopt.cc (tree_ssa_phiopt_worker):
            Change the code around slightly to move diamond
            handling for do_store_elim/do_hoist_loads out of
            the big if/else.

Diff:
---
 gcc/tree-ssa-phiopt.cc | 46 +++++++++++++++++++++-------------------------
 1 file changed, 21 insertions(+), 25 deletions(-)

diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc
index 8c5c8d8c250..d886c88215b 100644
--- a/gcc/tree-ssa-phiopt.cc
+++ b/gcc/tree-ssa-phiopt.cc
@@ -175,28 +175,38 @@ tree_ssa_phiopt_worker (bool do_store_elim, bool do_hoist_loads, bool early_p)
 	  std::swap (bb1, bb2);
 	  std::swap (e1, e2);
 	}
-      else if (do_store_elim
-	       && EDGE_SUCC (bb1, 0)->dest == EDGE_SUCC (bb2, 0)->dest)
+      else if (EDGE_SUCC (bb1, 0)->dest == EDGE_SUCC (bb2, 0)->dest)
+	{
+	  diamond_p = true;
+	  e2 = EDGE_SUCC (bb2, 0);
+	}
+      else
+	continue;
+
+      e1 = EDGE_SUCC (bb1, 0);
+
+      /* Make sure that bb1 is just a fall through.  */
+      if (!single_succ_p (bb1)
+	  || (e1->flags & EDGE_FALLTHRU) == 0)
+	continue;
+
+      if (do_store_elim && diamond_p)
 	{
-	  basic_block bb3 = EDGE_SUCC (bb1, 0)->dest;
+	  basic_block bb3 = e1->dest;
 
-	  if (!single_succ_p (bb1)
-	      || (EDGE_SUCC (bb1, 0)->flags & EDGE_FALLTHRU) == 0
-	      || !single_succ_p (bb2)
-	      || (EDGE_SUCC (bb2, 0)->flags & EDGE_FALLTHRU) == 0
+	  if (!single_succ_p (bb2)
+	      || (e2->flags & EDGE_FALLTHRU) == 0
 	      || EDGE_COUNT (bb3->preds) != 2)
 	    continue;
 	  if (cond_if_else_store_replacement (bb1, bb2, bb3))
 	    cfgchanged = true;
 	  continue;
 	}
-      else if (do_hoist_loads
-	       && EDGE_SUCC (bb1, 0)->dest == EDGE_SUCC (bb2, 0)->dest)
+      else if (do_hoist_loads && diamond_p)
 	{
-	  basic_block bb3 = EDGE_SUCC (bb1, 0)->dest;
+	  basic_block bb3 = e1->dest;
 
 	  if (!FLOAT_TYPE_P (TREE_TYPE (gimple_cond_lhs (cond_stmt)))
-	      && single_succ_p (bb1)
 	      && single_succ_p (bb2)
 	      && single_pred_p (bb1)
 	      && single_pred_p (bb2)
@@ -209,20 +219,6 @@ tree_ssa_phiopt_worker (bool do_store_elim, bool do_hoist_loads, bool early_p)
 	    hoist_adjacent_loads (bb, bb1, bb2, bb3);
 	  continue;
 	}
-      else if (EDGE_SUCC (bb1, 0)->dest == EDGE_SUCC (bb2, 0)->dest)
-	{
-	  diamond_p = true;
-	  e2 = EDGE_SUCC (bb2, 0);
-	}
-      else
-	continue;
-
-      e1 = EDGE_SUCC (bb1, 0);
-
-      /* Make sure that bb1 is just a fall through.  */
-      if (!single_succ_p (bb1)
-	  || (e1->flags & EDGE_FALLTHRU) == 0)
-        continue;
 
       if (do_store_elim && !diamond_p)
 	{

                 reply	other threads:[~2023-04-22 22:02 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230422220245.AD1353857739@sourceware.org \
    --to=pinskia@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).