From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1851) id 4B11C3858411; Wed, 8 Dec 2021 10:17:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4B11C3858411 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)] Simplify a bit. X-Act-Checkin: gcc X-Git-Author: Martin Liska X-Git-Refname: refs/users/marxin/heads/loop-unswitch-improvement-v7 X-Git-Oldrev: e5ec7532bf0ced046a00b659335d7971f42d5c0b X-Git-Newrev: 302ecbf8a4f413d305d097569c902ecf19630d81 Message-Id: <20211208101700.4B11C3858411@sourceware.org> Date: Wed, 8 Dec 2021 10:17:00 +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: Wed, 08 Dec 2021 10:17:00 -0000 https://gcc.gnu.org/g:302ecbf8a4f413d305d097569c902ecf19630d81 commit 302ecbf8a4f413d305d097569c902ecf19630d81 Author: Martin Liska 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 4bb108adc7c..7b5bd8afec7 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 - /* 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 (last) : NULL; + if (cond != NULL) { - gcond *cond = dyn_cast (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; } } }