From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1851) id 6143A385800C; Thu, 9 Dec 2021 12:49:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6143A385800C Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Martin Liska To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/marxin/heads/loop-unswitch-improvement-v7)] Fix switch bug! X-Act-Checkin: gcc X-Git-Author: Martin Liska X-Git-Refname: refs/users/marxin/heads/loop-unswitch-improvement-v7 X-Git-Oldrev: eddbc4643853ff8de4bcf5117750793decd2e1f5 X-Git-Newrev: 6fcc505ecb8675f32259db6259b91b289a1912f9 Message-Id: <20211209124902.6143A385800C@sourceware.org> Date: Thu, 9 Dec 2021 12:49:02 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Dec 2021 12:49:02 -0000 https://gcc.gnu.org/g:6fcc505ecb8675f32259db6259b91b289a1912f9 commit 6fcc505ecb8675f32259db6259b91b289a1912f9 Author: Martin Liska 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);