public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/marxin/heads/loop-unswitch-improvement-v6)] Simplify a bit.
@ 2021-12-06 14:34 Martin Liska
  0 siblings, 0 replies; 2+ messages in thread
From: Martin Liska @ 2021-12-06 14:34 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:6abb525cf75e3251445e3b53e507f6246645648d

commit 6abb525cf75e3251445e3b53e507f6246645648d
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 12fa6b86088..b808a350542 100644
--- a/gcc/tree-ssa-loop-unswitch.c
+++ b/gcc/tree-ssa-loop-unswitch.c
@@ -41,8 +41,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)
@@ -474,32 +472,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;
 		}
 	    }
 	}


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [gcc(refs/users/marxin/heads/loop-unswitch-improvement-v6)] Simplify a bit.
@ 2021-12-07 15:21 Martin Liska
  0 siblings, 0 replies; 2+ messages in thread
From: Martin Liska @ 2021-12-07 15:21 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:0f144022145fbb487d3c9bacc2677be3605b0717

commit 0f144022145fbb487d3c9bacc2677be3605b0717
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 12fa6b86088..b808a350542 100644
--- a/gcc/tree-ssa-loop-unswitch.c
+++ b/gcc/tree-ssa-loop-unswitch.c
@@ -41,8 +41,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)
@@ -474,32 +472,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;
 		}
 	    }
 	}


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-12-07 15:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-06 14:34 [gcc(refs/users/marxin/heads/loop-unswitch-improvement-v6)] Simplify a bit Martin Liska
2021-12-07 15:21 Martin Liska

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).