public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/marxin/heads/loop-unswitch-improvement-v7)] Fix switch bug!
@ 2021-12-08 11:14 Martin Liska
  0 siblings, 0 replies; 3+ messages in thread
From: Martin Liska @ 2021-12-08 11:14 UTC (permalink / raw)
  To: gcc-cvs

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

commit a3ba6f3bb9dff3289345e7b84642c76350502bb9
Author: Martin Liska <mliska@suse.cz>
Date:   Wed Dec 8 12:14:27 2021 +0100

    Fix switch bug!
    
    And add comments.

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

diff --git a/gcc/tree-ssa-loop-unswitch.c b/gcc/tree-ssa-loop-unswitch.c
index 811f0cad343..d80b34db861 100644
--- a/gcc/tree-ssa-loop-unswitch.c
+++ b/gcc/tree-ssa-loop-unswitch.c
@@ -90,6 +90,8 @@ struct unswitch_predicate
     edge_index (edge_index_), handled (false)
   {}
 
+  /* Based on true_range, compute inverted range.  */
+
   inline void
   init_false_edge (void)
   {
@@ -100,6 +102,8 @@ struct unswitch_predicate
       false_range.invert ();
   }
 
+  /* Copy ranges for purpose of usage in predicate path.  */
+
   inline void
   copy_merged_ranges ()
   {
@@ -107,11 +111,22 @@ struct unswitch_predicate
     merged_false_range = false_range;
   }
 
+  /* Unswitching expression.  */
   tree condition;
+
+  /* LHS of the expression.  */
   tree lhs;
+
+  /* Initial ranges (when the expression is true/false) for the expression.  */
   int_range_max true_range, false_range;
+
+  /* Modified range that is part of a predicate path.  */
   int_range_max merged_true_range, merged_false_range;
+
+  /* For switch predicates, index of the edge the predicate belongs to.  */
   int edge_index;
+
+  /* True if the predicate was already used for unswitching.  */
   bool handled;
 };
 
@@ -451,6 +466,12 @@ find_unswitching_predicates_for_bb (basic_block bb, class loop *loop,
 		  unswitch_predicate *predicate = new unswitch_predicate (expr, idx, edge_index);
 		  ranger->gori().outgoing_edge_range_p (predicate->true_range, e,
 							idx, *get_global_range_query  ());
+		  /* Huge switches are not supported by Ranger.  */
+		  if (predicate->true_range.undefined_p ())
+		    {
+		      delete predicate;
+		      return;
+		    }
 		  predicate->init_false_edge ();
 
 		  candidates.safe_push (predicate);


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

* [gcc(refs/users/marxin/heads/loop-unswitch-improvement-v7)] Fix switch bug!
@ 2021-12-09 12:49 Martin Liska
  0 siblings, 0 replies; 3+ messages in thread
From: Martin Liska @ 2021-12-09 12:49 UTC (permalink / raw)
  To: gcc-cvs

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

commit 6fcc505ecb8675f32259db6259b91b289a1912f9
Author: Martin Liska <mliska@suse.cz>
Date:   Wed Dec 8 12:14:27 2021 +0100

    Fix switch bug!
    
    And add comments.

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

diff --git a/gcc/tree-ssa-loop-unswitch.c b/gcc/tree-ssa-loop-unswitch.c
index b083d990d4c..8a0feba862f 100644
--- a/gcc/tree-ssa-loop-unswitch.c
+++ b/gcc/tree-ssa-loop-unswitch.c
@@ -91,6 +91,8 @@ struct unswitch_predicate
     edge_index (edge_index_), handled (false)
   {}
 
+  /* Based on true_range, compute inverted range.  */
+
   inline void
   init_false_edge (void)
   {
@@ -101,6 +103,8 @@ struct unswitch_predicate
       false_range.invert ();
   }
 
+  /* Copy ranges for purpose of usage in predicate path.  */
+
   inline void
   copy_merged_ranges ()
   {
@@ -108,11 +112,22 @@ struct unswitch_predicate
     merged_false_range = false_range;
   }
 
+  /* Unswitching expression.  */
   tree condition;
+
+  /* LHS of the expression.  */
   tree lhs;
+
+  /* Initial ranges (when the expression is true/false) for the expression.  */
   int_range_max true_range, false_range;
+
+  /* Modified range that is part of a predicate path.  */
   int_range_max merged_true_range, merged_false_range;
+
+  /* For switch predicates, index of the edge the predicate belongs to.  */
   int edge_index;
+
+  /* True if the predicate was already used for unswitching.  */
   bool handled;
 };
 
@@ -452,6 +467,12 @@ find_unswitching_predicates_for_bb (basic_block bb, class loop *loop,
 		  unswitch_predicate *predicate = new unswitch_predicate (expr, idx, edge_index);
 		  ranger->gori().outgoing_edge_range_p (predicate->true_range, e,
 							idx, *get_global_range_query  ());
+		  /* Huge switches are not supported by Ranger.  */
+		  if (predicate->true_range.undefined_p ())
+		    {
+		      delete predicate;
+		      return;
+		    }
 		  predicate->init_false_edge ();
 
 		  candidates.safe_push (predicate);


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

* [gcc(refs/users/marxin/heads/loop-unswitch-improvement-v7)] Fix switch bug!
@ 2021-12-08 18:26 Martin Liska
  0 siblings, 0 replies; 3+ messages in thread
From: Martin Liska @ 2021-12-08 18:26 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:1f11abd53df9ae8f521f7e235f49e91dfeeea598

commit 1f11abd53df9ae8f521f7e235f49e91dfeeea598
Author: Martin Liska <mliska@suse.cz>
Date:   Wed Dec 8 12:14:27 2021 +0100

    Fix switch bug!
    
    And add comments.

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

diff --git a/gcc/tree-ssa-loop-unswitch.c b/gcc/tree-ssa-loop-unswitch.c
index b083d990d4c..8a0feba862f 100644
--- a/gcc/tree-ssa-loop-unswitch.c
+++ b/gcc/tree-ssa-loop-unswitch.c
@@ -91,6 +91,8 @@ struct unswitch_predicate
     edge_index (edge_index_), handled (false)
   {}
 
+  /* Based on true_range, compute inverted range.  */
+
   inline void
   init_false_edge (void)
   {
@@ -101,6 +103,8 @@ struct unswitch_predicate
       false_range.invert ();
   }
 
+  /* Copy ranges for purpose of usage in predicate path.  */
+
   inline void
   copy_merged_ranges ()
   {
@@ -108,11 +112,22 @@ struct unswitch_predicate
     merged_false_range = false_range;
   }
 
+  /* Unswitching expression.  */
   tree condition;
+
+  /* LHS of the expression.  */
   tree lhs;
+
+  /* Initial ranges (when the expression is true/false) for the expression.  */
   int_range_max true_range, false_range;
+
+  /* Modified range that is part of a predicate path.  */
   int_range_max merged_true_range, merged_false_range;
+
+  /* For switch predicates, index of the edge the predicate belongs to.  */
   int edge_index;
+
+  /* True if the predicate was already used for unswitching.  */
   bool handled;
 };
 
@@ -452,6 +467,12 @@ find_unswitching_predicates_for_bb (basic_block bb, class loop *loop,
 		  unswitch_predicate *predicate = new unswitch_predicate (expr, idx, edge_index);
 		  ranger->gori().outgoing_edge_range_p (predicate->true_range, e,
 							idx, *get_global_range_query  ());
+		  /* Huge switches are not supported by Ranger.  */
+		  if (predicate->true_range.undefined_p ())
+		    {
+		      delete predicate;
+		      return;
+		    }
 		  predicate->init_false_edge ();
 
 		  candidates.safe_push (predicate);


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

end of thread, other threads:[~2021-12-09 12:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-08 11:14 [gcc(refs/users/marxin/heads/loop-unswitch-improvement-v7)] Fix switch bug! Martin Liska
2021-12-08 18:26 Martin Liska
2021-12-09 12:49 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).