public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Martin Liska <marxin@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc(refs/users/marxin/heads/loop-unswitch-improvement-v7)] Simplify a bit.
Date: Thu,  9 Dec 2021 12:47:46 +0000 (GMT)	[thread overview]
Message-ID: <20211209124746.476AD3858439@sourceware.org> (raw)

https://gcc.gnu.org/g:26a704a8081e834c2ce67142df3aece8e65c78af

commit 26a704a8081e834c2ce67142df3aece8e65c78af
Author: Martin Liska <mliska@suse.cz>
Date:   Tue Nov 30 17:30:16 2021 +0100

    Simplify a bit.

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

diff --git a/gcc/tree-ssa-loop-unswitch.c b/gcc/tree-ssa-loop-unswitch.c
index 10804cf4b1e..bd71e9d9fbd 100644
--- a/gcc/tree-ssa-loop-unswitch.c
+++ b/gcc/tree-ssa-loop-unswitch.c
@@ -42,8 +42,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "gimple-range.h"
 #include "dbgcnt.h"
 
-#include <utility>
-
 /* This file implements the loop unswitching, i.e. transformation of loops like
 
    while (A)
@@ -475,32 +473,30 @@ evaluate_insns (class loop *loop, basic_block *bbs,
       int flags = 0;
       basic_block bb = worklist.pop ();
 
-      if (EDGE_COUNT (bb->succs) == 2)
+      gimple *last = last_stmt (bb);
+      gcond *cond = last != NULL ? dyn_cast<gcond *> (last) : NULL;
+      if (cond != NULL)
 	{
-	  gcond *cond = dyn_cast<gcond *> (last_stmt (bb));
-	  if (cond != NULL)
+	  if (gimple_cond_true_p (cond))
+	    flags = EDGE_FALSE_VALUE;
+	  else if (gimple_cond_false_p (cond))
+	    flags = EDGE_TRUE_VALUE;
+	  else
 	    {
-	      if (gimple_cond_true_p (cond))
-		flags = EDGE_FALSE_VALUE;
-	      else if (gimple_cond_false_p (cond))
-		flags = EDGE_TRUE_VALUE;
-	      else
+	      // FIXME: works only for gconds
+	      unswitch_predicate *predicate = NULL;
+	      if (!get_predicates_for_bb (bb).is_empty ())
+		predicate = get_predicates_for_bb (bb)[0];
+
+	      if (predicate != NULL)
 		{
-		  // FIXME: works only for gconds
-		  unswitch_predicate *predicate = NULL;
-		  if (!get_predicates_for_bb (bb).is_empty ())
-		    predicate = get_predicates_for_bb (bb)[0];
-
-		  if (predicate != NULL)
-		    {
-		      tree folded
-			= evaluate_control_stmt_using_entry_checks (cond,
-								    predicate_path);
-		      if (folded == boolean_true_node)
-			flags = EDGE_FALSE_VALUE;
-		      else if (folded == boolean_false_node)
-			flags = EDGE_TRUE_VALUE;
-		    }
+		  tree folded
+		    = evaluate_control_stmt_using_entry_checks (cond,
+								predicate_path);
+		  if (folded == boolean_true_node)
+		    flags = EDGE_FALSE_VALUE;
+		  else if (folded == boolean_false_node)
+		    flags = EDGE_TRUE_VALUE;
 		}
 	    }
 	}


             reply	other threads:[~2021-12-09 12:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-09 12:47 Martin Liska [this message]
  -- strict thread matches above, loose matches on Subject: below --
2021-12-08 18:25 Martin Liska
2021-12-08 10:17 Martin Liska
2021-12-07 16:49 Martin Liska

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=20211209124746.476AD3858439@sourceware.org \
    --to=marxin@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).