From adb7eaa2bac31047b37cc8b9cb7b4121ca0a8fea Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Mon, 19 Jun 2017 07:26:50 +0000 Subject: [PATCH] tree-ssa-loop-niter.h (estimate_numbers_of_iterations): Take struct function as arg. 2017-06-19 Richard Biener * tree-ssa-loop-niter.h (estimate_numbers_of_iterations): Take struct function as arg. (estimate_numbers_of_iterations): Export overload with loop arg. (free_numbers_of_iterations_estimates_loop): Use an overload of free_numbers_of_iterations_estimates instead. * tree-cfg.c (remove_bb): Adjust. * tree-cfgcleanup.c (remove_forwarder_block_with_phi): Likewise. * tree-parloops.c (gen_parallel_loop): Likewise. * tree-ssa-loop-ivcanon.c (canonicalize_induction_variables): Likewise. (tree_unroll_loops_completely): Likewise. * tree-ssa-loop-niter.c (estimate_numbers_of_iterations_loop): Use an overload instead and export. (estimated_loop_iterations): Adjust. (max_loop_iterations): Likewise. (likely_max_loop_iterations): Likewise. (estimate_numbers_of_iterations): Take struct function as arg and adjust. (loop_exits_before_overflow): Adjust. (free_numbers_of_iterations_estimates_loop): Use an overload. * tree-vect-loop.c (vect_analyze_loop_form): Adjust. * tree-vectorizer.c (vect_free_loop_info_assumptions): Likewise. From-SVN: r249358 --- gcc/ChangeLog | 25 +++++++++++++++++++++++++ gcc/tree-cfg.c | 2 +- gcc/tree-cfgcleanup.c | 2 +- gcc/tree-parloops.c | 3 +-- gcc/tree-ssa-loop-ivcanon.c | 7 ++++--- gcc/tree-ssa-loop-niter.c | 26 +++++++++++--------------- gcc/tree-ssa-loop-niter.h | 6 +++--- gcc/tree-vect-loop.c | 2 +- gcc/tree-vectorizer.c | 4 ++-- 9 files changed, 49 insertions(+), 28 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 60d315500ab3..49a8109df1d2 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,28 @@ +2017-06-19 Richard Biener + + * tree-ssa-loop-niter.h (estimate_numbers_of_iterations): Take + struct function as arg. + (estimate_numbers_of_iterations): Export overload with loop arg. + (free_numbers_of_iterations_estimates_loop): Use an overload of + free_numbers_of_iterations_estimates instead. + * tree-cfg.c (remove_bb): Adjust. + * tree-cfgcleanup.c (remove_forwarder_block_with_phi): Likewise. + * tree-parloops.c (gen_parallel_loop): Likewise. + * tree-ssa-loop-ivcanon.c (canonicalize_induction_variables): + Likewise. + (tree_unroll_loops_completely): Likewise. + * tree-ssa-loop-niter.c (estimate_numbers_of_iterations_loop): + Use an overload instead and export. + (estimated_loop_iterations): Adjust. + (max_loop_iterations): Likewise. + (likely_max_loop_iterations): Likewise. + (estimate_numbers_of_iterations): Take struct function as arg + and adjust. + (loop_exits_before_overflow): Adjust. + (free_numbers_of_iterations_estimates_loop): Use an overload. + * tree-vect-loop.c (vect_analyze_loop_form): Adjust. + * tree-vectorizer.c (vect_free_loop_info_assumptions): Likewise. + 2017-06-19 Richard Biener PR ipa/81112 diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index 7df80f8ee8c6..589508df0443 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -2177,7 +2177,7 @@ remove_bb (basic_block bb) with it. */ if (loop->latch == bb || loop->header == bb) - free_numbers_of_iterations_estimates_loop (loop); + free_numbers_of_iterations_estimates (loop); } /* Remove all the instructions in the block. */ diff --git a/gcc/tree-cfgcleanup.c b/gcc/tree-cfgcleanup.c index 94a172fa98e4..4cab592ee772 100644 --- a/gcc/tree-cfgcleanup.c +++ b/gcc/tree-cfgcleanup.c @@ -959,7 +959,7 @@ remove_forwarder_block_with_phi (basic_block bb) { dest->loop_father->any_upper_bound = false; dest->loop_father->any_likely_upper_bound = false; - free_numbers_of_iterations_estimates_loop (dest->loop_father); + free_numbers_of_iterations_estimates (dest->loop_father); } } diff --git a/gcc/tree-parloops.c b/gcc/tree-parloops.c index 641f675edf74..79d616b760ad 100644 --- a/gcc/tree-parloops.c +++ b/gcc/tree-parloops.c @@ -2436,8 +2436,7 @@ gen_parallel_loop (struct loop *loop, /* Free loop bound estimations that could contain references to removed statements. */ - FOR_EACH_LOOP (loop, 0) - free_numbers_of_iterations_estimates_loop (loop); + free_numbers_of_iterations_estimates (cfun); } /* Returns true when LOOP contains vector phi nodes. */ diff --git a/gcc/tree-ssa-loop-ivcanon.c b/gcc/tree-ssa-loop-ivcanon.c index 82ad59c42530..b6ac765aac69 100644 --- a/gcc/tree-ssa-loop-ivcanon.c +++ b/gcc/tree-ssa-loop-ivcanon.c @@ -1215,7 +1215,7 @@ canonicalize_induction_variables (void) bool irred_invalidated = false; bitmap loop_closed_ssa_invalidated = BITMAP_ALLOC (NULL); - estimate_numbers_of_iterations (); + estimate_numbers_of_iterations (cfun); FOR_EACH_LOOP (loop, LI_FROM_INNERMOST) { @@ -1361,6 +1361,8 @@ tree_unroll_loops_completely (bool may_increase_size, bool unroll_outer) int iteration = 0; bool irred_invalidated = false; + estimate_numbers_of_iterations (cfun); + do { changed = false; @@ -1370,7 +1372,7 @@ tree_unroll_loops_completely (bool may_increase_size, bool unroll_outer) loop_closed_ssa_invalidated = BITMAP_ALLOC (NULL); free_numbers_of_iterations_estimates (cfun); - estimate_numbers_of_iterations (); + estimate_numbers_of_iterations (cfun); changed = tree_unroll_loops_completely_1 (may_increase_size, unroll_outer, father_bbs, @@ -1588,7 +1590,6 @@ pass_complete_unrolli::execute (function *fun) { scev_initialize (); ret = tree_unroll_loops_completely (optimize >= 3, false); - free_numbers_of_iterations_estimates (fun); scev_finalize (); } loop_optimizer_finalize (); diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c index b1f14078b4fa..848e812cb96b 100644 --- a/gcc/tree-ssa-loop-niter.c +++ b/gcc/tree-ssa-loop-niter.c @@ -3786,8 +3786,8 @@ maybe_lower_iteration_bound (struct loop *loop) /* Records estimates on numbers of iterations of LOOP. If USE_UNDEFINED_P is true also use estimates derived from undefined behavior. */ -static void -estimate_numbers_of_iterations_loop (struct loop *loop) +void +estimate_numbers_of_iterations (struct loop *loop) { vec exits; tree niter, type; @@ -3876,7 +3876,7 @@ estimated_loop_iterations (struct loop *loop, widest_int *nit) /* When SCEV information is available, try to update loop iterations estimate. Otherwise just return whatever we recorded earlier. */ if (scev_initialized_p ()) - estimate_numbers_of_iterations_loop (loop); + estimate_numbers_of_iterations (loop); return (get_estimated_loop_iterations (loop, nit)); } @@ -3912,7 +3912,7 @@ max_loop_iterations (struct loop *loop, widest_int *nit) /* When SCEV information is available, try to update loop iterations estimate. Otherwise just return whatever we recorded earlier. */ if (scev_initialized_p ()) - estimate_numbers_of_iterations_loop (loop); + estimate_numbers_of_iterations (loop); return get_max_loop_iterations (loop, nit); } @@ -3947,7 +3947,7 @@ likely_max_loop_iterations (struct loop *loop, widest_int *nit) /* When SCEV information is available, try to update loop iterations estimate. Otherwise just return whatever we recorded earlier. */ if (scev_initialized_p ()) - estimate_numbers_of_iterations_loop (loop); + estimate_numbers_of_iterations (loop); return get_likely_max_loop_iterations (loop, nit); } @@ -4051,7 +4051,7 @@ estimated_stmt_executions (struct loop *loop, widest_int *nit) /* Records estimates on numbers of iterations of loops. */ void -estimate_numbers_of_iterations (void) +estimate_numbers_of_iterations (function *fn) { struct loop *loop; @@ -4059,10 +4059,8 @@ estimate_numbers_of_iterations (void) loop iteration estimates. */ fold_defer_overflow_warnings (); - FOR_EACH_LOOP (loop, 0) - { - estimate_numbers_of_iterations_loop (loop); - } + FOR_EACH_LOOP_FN (fn, loop, 0) + estimate_numbers_of_iterations (loop); fold_undefer_and_ignore_overflow_warnings (); } @@ -4235,7 +4233,7 @@ loop_exits_before_overflow (tree base, tree step, valid_niter = fold_build2 (FLOOR_DIV_EXPR, unsigned_type, delta, step_abs); - estimate_numbers_of_iterations_loop (loop); + estimate_numbers_of_iterations (loop); if (max_loop_iterations (loop, &niter) && wi::fits_to_tree_p (niter, TREE_TYPE (valid_niter)) @@ -4502,7 +4500,7 @@ scev_probably_wraps_p (tree var, tree base, tree step, /* Frees the information on upper bounds on numbers of iterations of LOOP. */ void -free_numbers_of_iterations_estimates_loop (struct loop *loop) +free_numbers_of_iterations_estimates (struct loop *loop) { struct control_iv *civ; struct nb_iter_bound *bound; @@ -4534,9 +4532,7 @@ free_numbers_of_iterations_estimates (function *fn) struct loop *loop; FOR_EACH_LOOP_FN (fn, loop, 0) - { - free_numbers_of_iterations_estimates_loop (loop); - } + free_numbers_of_iterations_estimates (loop); } /* Substitute value VAL for ssa name NAME inside expressions held diff --git a/gcc/tree-ssa-loop-niter.h b/gcc/tree-ssa-loop-niter.h index b0098570d09a..8161cc76fd73 100644 --- a/gcc/tree-ssa-loop-niter.h +++ b/gcc/tree-ssa-loop-niter.h @@ -45,13 +45,13 @@ extern HOST_WIDE_INT estimated_stmt_executions_int (struct loop *); extern bool max_stmt_executions (struct loop *, widest_int *); extern bool likely_max_stmt_executions (struct loop *, widest_int *); extern bool estimated_stmt_executions (struct loop *, widest_int *); -extern void estimate_numbers_of_iterations (void); +extern void estimate_numbers_of_iterations (function *); +extern void estimate_numbers_of_iterations (struct loop *); extern bool stmt_dominates_stmt_p (gimple *, gimple *); extern bool nowrap_type_p (tree); extern bool scev_probably_wraps_p (tree, tree, tree, gimple *, struct loop *, bool); -extern void free_loop_control_ivs (struct loop *); -extern void free_numbers_of_iterations_estimates_loop (struct loop *); +extern void free_numbers_of_iterations_estimates (struct loop *); extern void free_numbers_of_iterations_estimates (function *); extern void substitute_in_loop_info (struct loop *, tree, tree); diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c index b8b49c9fde45..d601296ab3e4 100644 --- a/gcc/tree-vect-loop.c +++ b/gcc/tree-vect-loop.c @@ -1570,7 +1570,7 @@ vect_analyze_loop_form (struct loop *loop) some assumptions. In order to do this, we need to clear existing information computed by scev and niter analyzer. */ scev_reset_htab (); - free_numbers_of_iterations_estimates_loop (loop); + free_numbers_of_iterations_estimates (loop); /* Also set flag for this loop so that following scev and niter analysis are done under the assumptions. */ loop_constraint_set (loop, LOOP_C_FINITE); diff --git a/gcc/tree-vectorizer.c b/gcc/tree-vectorizer.c index 1bef2e4f800a..0d62c829ef58 100644 --- a/gcc/tree-vectorizer.c +++ b/gcc/tree-vectorizer.c @@ -380,10 +380,10 @@ vect_free_loop_info_assumptions (struct loop *loop) { scev_reset_htab (); /* We need to explicitly reset upper bound information since they are - used even after free_numbers_of_iterations_estimates_loop. */ + used even after free_numbers_of_iterations_estimates. */ loop->any_upper_bound = false; loop->any_likely_upper_bound = false; - free_numbers_of_iterations_estimates_loop (loop); + free_numbers_of_iterations_estimates (loop); loop_constraint_clear (loop, LOOP_C_FINITE); } -- 2.39.5