From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1851) id 8216B3858018; Wed, 24 Nov 2021 14:33:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8216B3858018 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-v3)] small tweaks. X-Act-Checkin: gcc X-Git-Author: Martin Liska X-Git-Refname: refs/users/marxin/heads/loop-unswitch-improvement-v3 X-Git-Oldrev: 34f92a4fb42e8d14b90c1ee5803c4ae3b0b81343 X-Git-Newrev: d1c5ce63cd41244bcc0c96f664952ff46e5388e0 Message-Id: <20211124143357.8216B3858018@sourceware.org> Date: Wed, 24 Nov 2021 14:33:57 +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, 24 Nov 2021 14:33:57 -0000 https://gcc.gnu.org/g:d1c5ce63cd41244bcc0c96f664952ff46e5388e0 commit d1c5ce63cd41244bcc0c96f664952ff46e5388e0 Author: Martin Liska Date: Tue Nov 23 16:30:45 2021 +0100 small tweaks. Diff: --- gcc/tree-ssa-loop-unswitch.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/gcc/tree-ssa-loop-unswitch.c b/gcc/tree-ssa-loop-unswitch.c index 6895e5b8bb9..57ddd769b31 100644 --- a/gcc/tree-ssa-loop-unswitch.c +++ b/gcc/tree-ssa-loop-unswitch.c @@ -455,7 +455,7 @@ static bool tree_unswitch_single_loop (class loop *loop, int num, gimple_ranger *ranger, unswitch_predicate *parent_predicate, bool true_edge) { - basic_block *bbs; + basic_block *bbs = NULL; class loop *nloop; bool changed = false; HOST_WIDE_INT iterations; @@ -485,14 +485,9 @@ tree_unswitch_single_loop (class loop *loop, int num, gimple_ranger *ranger, } } - bbs = get_loop_body (loop); auto_vec candidates; - - changed = find_all_unswitching_predicates (loop, bbs, true_edge, - parent_predicate, ranger, - candidates); - unswitch_predicate *predicate = NULL; + if (num > param_max_unswitch_level) { if (dump_file @@ -501,11 +496,18 @@ tree_unswitch_single_loop (class loop *loop, int num, gimple_ranger *ranger, goto exit; } + bbs = get_loop_body (loop); + changed = find_all_unswitching_predicates (loop, bbs, true_edge, + parent_predicate, ranger, + candidates); + for (auto pred: candidates) { unsigned cost = evaluate_loop_insns_for_predicate (loop, bbs, ranger, pred); + /* FIXME: right now we select first candidate, but we can choose + a cheapest (best) one. */ if (cost <= (unsigned)param_max_unswitch_insns) { predicate = pred; @@ -513,7 +515,7 @@ tree_unswitch_single_loop (class loop *loop, int num, gimple_ranger *ranger, } else if (dump_file && (dump_flags & TDF_DETAILS)) { - fprintf (dump_file, ";; Not unswitching condition, loop too big " + fprintf (dump_file, ";; Not unswitching condition, cost too big " "(%d insns): ", cost); print_generic_expr (dump_file, pred->condition); fprintf (dump_file, "\n"); @@ -527,7 +529,7 @@ tree_unswitch_single_loop (class loop *loop, int num, gimple_ranger *ranger, if (dump_file && (dump_flags & TDF_DETAILS)) { - fprintf (dump_file, ";; Unswitching loop with condition: "); + fprintf (dump_file, ";; Unswitching loop on condition: "); print_generic_expr (dump_file, predicate->condition); fprintf (dump_file, "\n"); }