From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1851) id 7125E3877411; Mon, 29 Nov 2021 11:13:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7125E3877411 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)] Add comments, fix various tweaks. X-Act-Checkin: gcc X-Git-Author: Martin Liska X-Git-Refname: refs/users/marxin/heads/loop-unswitch-improvement-v3 X-Git-Oldrev: 2b9aafc9634370bcb650b230fb63258a6eb0a3e1 X-Git-Newrev: 5b3da0045f3f572ec55ab7c48ec95d3753c4fe02 Message-Id: <20211129111344.7125E3877411@sourceware.org> Date: Mon, 29 Nov 2021 11:13:44 +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: Mon, 29 Nov 2021 11:13:44 -0000 https://gcc.gnu.org/g:5b3da0045f3f572ec55ab7c48ec95d3753c4fe02 commit 5b3da0045f3f572ec55ab7c48ec95d3753c4fe02 Author: Martin Liska Date: Mon Nov 29 11:55:43 2021 +0100 Add comments, fix various tweaks. Diff: --- gcc/tree-ssa-loop-unswitch.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/gcc/tree-ssa-loop-unswitch.c b/gcc/tree-ssa-loop-unswitch.c index 1d5bcfc3237..a41c25784f3 100644 --- a/gcc/tree-ssa-loop-unswitch.c +++ b/gcc/tree-ssa-loop-unswitch.c @@ -95,10 +95,13 @@ struct unswitch_predicate int_range_max false_range; }; +/* Cache storage for unswitch_predicate belonging to a basic block. */ static vec> *bb_predicates = NULL; +/* Ranger instance used in the pass. */ static gimple_ranger *ranger = NULL; +/* The type represents a predicate path leading to a basic block. */ typedef auto_vec> predicate_vector; static class loop *tree_unswitch_loop (class loop *, basic_block, tree); @@ -115,6 +118,8 @@ static void hoist_guard (class loop *, edge); static bool check_exit_phi (class loop *); static tree get_vop_from_header (class loop *); +/* Return vector of predicates that belong to a basic block. */ + static vec & get_predicates_for_bb (basic_block bb) { @@ -122,6 +127,8 @@ get_predicates_for_bb (basic_block bb) return (*bb_predicates)[last == NULL ? 0 : gimple_uid (last)]; } +/* Save predicates that belong to a basic block. */ + static void set_predicates_for_bb (basic_block bb, vec predicates) { @@ -129,6 +136,8 @@ set_predicates_for_bb (basic_block bb, vec predicates) bb_predicates->safe_push (predicates); } +/* Initialize LOOP information reused during the unswitching pass. */ + static void init_loop_unswitch_info (class loop *loop) { @@ -193,7 +202,9 @@ tree_ssa_unswitch_loops (void) changed |= tree_unswitch_outer_loop (loop); } + disable_ranger (cfun); + clear_aux_for_blocks (); if (changed) return TODO_cleanup_cfg; @@ -366,7 +377,8 @@ combine_range (predicate_vector &predicate_path, tree index, irange &path_range) Utilize both symbolic expressions and value ranges calculated by Ranger. */ static tree -simplify_using_entry_checks (gimple *stmt, predicate_vector &predicate_path) +evaluate_control_stmt_using_entry_checks (gimple *stmt, + predicate_vector &predicate_path) { if (predicate_path.is_empty ()) return NULL_TREE; @@ -415,7 +427,8 @@ simplify_loop_version (class loop *loop, predicate_vector &predicate_path) { gimple *stmt = last_stmt (bbs[i]); - tree folded = simplify_using_entry_checks (stmt, predicate_path); + tree folded = evaluate_control_stmt_using_entry_checks (stmt, + predicate_path); if (folded != NULL_TREE) { /* Remove path. */ @@ -475,7 +488,8 @@ evaluate_insns (class loop *loop, basic_block *bbs, if (predicate != NULL) { tree folded - = simplify_using_entry_checks (cond, predicate_path); + = evaluate_control_stmt_using_entry_checks (cond, + predicate_path); if (folded == boolean_true_node) flags = EDGE_FALSE_VALUE; else if (folded == boolean_false_node)