This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Make niter estimate compute/free interfaces consistent


Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

2017-06-19  Richard Biener  <rguenther@suse.de>

	* 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.

Index: gcc/tree-cfg.c
===================================================================
--- gcc/tree-cfg.c	(revision 249357)
+++ gcc/tree-cfg.c	(working copy)
@@ -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.  */
Index: gcc/tree-cfgcleanup.c
===================================================================
--- gcc/tree-cfgcleanup.c	(revision 249357)
+++ gcc/tree-cfgcleanup.c	(working copy)
@@ -959,7 +959,7 @@ remove_forwarder_block_with_phi (basic_b
 	    {
 	      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);
 	    }
 	}
 
Index: gcc/tree-parloops.c
===================================================================
--- gcc/tree-parloops.c	(revision 249357)
+++ gcc/tree-parloops.c	(working copy)
@@ -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.  */
Index: gcc/tree-ssa-loop-ivcanon.c
===================================================================
--- gcc/tree-ssa-loop-ivcanon.c	(revision 249357)
+++ gcc/tree-ssa-loop-ivcanon.c	(working copy)
@@ -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_i
   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_i
 	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
     {
       scev_initialize ();
       ret = tree_unroll_loops_completely (optimize >= 3, false);
-      free_numbers_of_iterations_estimates (fun);
       scev_finalize ();
     }
   loop_optimizer_finalize ();
Index: gcc/tree-ssa-loop-niter.c
===================================================================
--- gcc/tree-ssa-loop-niter.c	(revision 249357)
+++ gcc/tree-ssa-loop-niter.c	(working copy)
@@ -3786,8 +3786,8 @@ maybe_lower_iteration_bound (struct 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<edge> exits;
   tree niter, type;
@@ -3876,7 +3876,7 @@ estimated_loop_iterations (struct loop *
   /* 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,
   /* 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
   /* 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 *
 /* 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, t
 
   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 ba
 /* 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 (fu
   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
Index: gcc/tree-ssa-loop-niter.h
===================================================================
--- gcc/tree-ssa-loop-niter.h	(revision 249357)
+++ gcc/tree-ssa-loop-niter.h	(working copy)
@@ -45,13 +45,13 @@ extern HOST_WIDE_INT estimated_stmt_exec
 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);
 
Index: gcc/tree-vect-loop.c
===================================================================
--- gcc/tree-vect-loop.c	(revision 249357)
+++ gcc/tree-vect-loop.c	(working copy)
@@ -1570,7 +1570,7 @@ vect_analyze_loop_form (struct loop *loo
 	 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);
Index: gcc/tree-vectorizer.c
===================================================================
--- gcc/tree-vectorizer.c	(revision 249357)
+++ gcc/tree-vectorizer.c	(working copy)
@@ -380,10 +380,10 @@ vect_free_loop_info_assumptions (struct
 {
   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);
 }
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]