Commit 03fd03d5 by Richard Guenther Committed by Richard Biener

re PR tree-optimization/44688 (Excessive code-size growth at -O3)

2012-04-18  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/44688
	* cfgloop.h (record_niter_bound): Declare.
	* tree-ssa-loop-niter.c (record_niter_bound): Export.
	Update the estimation with the upper bound here...
	(estimate_numbers_of_iterations_loop): ... instead of here.
	Do not forcefully reset a recorded upper bound.
	* tree-vect-loop-manip.c (vect_do_peeling_for_alignment):
	Record the maximum number of loop iterations of the
	prologue loop.

From-SVN: r186566
parent 89fcabaf
2012-04-18 Richard Guenther <rguenther@suse.de>
PR tree-optimization/44688
* cfgloop.h (record_niter_bound): Declare.
* tree-ssa-loop-niter.c (record_niter_bound): Export.
Update the estimation with the upper bound here...
(estimate_numbers_of_iterations_loop): ... instead of here.
Do not forcefully reset a recorded upper bound.
* tree-vect-loop-manip.c (vect_do_peeling_for_alignment):
Record the maximum number of loop iterations of the
prologue loop.
2012-04-18 Jan Hubicka <jh@suse.cz> 2012-04-18 Jan Hubicka <jh@suse.cz>
* lto-symtab.c (lto_cgraph_replace_node): Update. * lto-symtab.c (lto_cgraph_replace_node): Update.
......
...@@ -279,6 +279,7 @@ extern unsigned expected_loop_iterations (const struct loop *); ...@@ -279,6 +279,7 @@ extern unsigned expected_loop_iterations (const struct loop *);
extern rtx doloop_condition_get (rtx); extern rtx doloop_condition_get (rtx);
void estimate_numbers_of_iterations_loop (struct loop *); void estimate_numbers_of_iterations_loop (struct loop *);
void record_niter_bound (struct loop *, double_int, bool, bool);
bool estimated_loop_iterations (struct loop *, double_int *); bool estimated_loop_iterations (struct loop *, double_int *);
bool max_loop_iterations (struct loop *, double_int *); bool max_loop_iterations (struct loop *, double_int *);
HOST_WIDE_INT estimated_loop_iterations_int (struct loop *); HOST_WIDE_INT estimated_loop_iterations_int (struct loop *);
......
...@@ -2494,12 +2494,12 @@ derive_constant_upper_bound_ops (tree type, tree op0, ...@@ -2494,12 +2494,12 @@ derive_constant_upper_bound_ops (tree type, tree op0,
of iterations. UPPER is true if we are sure the loop iterates at most of iterations. UPPER is true if we are sure the loop iterates at most
I_BOUND times. */ I_BOUND times. */
static void void
record_niter_bound (struct loop *loop, double_int i_bound, bool realistic, record_niter_bound (struct loop *loop, double_int i_bound, bool realistic,
bool upper) bool upper)
{ {
/* Update the bounds only when there is no previous estimation, or when the current /* Update the bounds only when there is no previous estimation, or when the
estimation is smaller. */ current estimation is smaller. */
if (upper if (upper
&& (!loop->any_upper_bound && (!loop->any_upper_bound
|| double_int_ucmp (i_bound, loop->nb_iterations_upper_bound) < 0)) || double_int_ucmp (i_bound, loop->nb_iterations_upper_bound) < 0))
...@@ -2514,6 +2514,14 @@ record_niter_bound (struct loop *loop, double_int i_bound, bool realistic, ...@@ -2514,6 +2514,14 @@ record_niter_bound (struct loop *loop, double_int i_bound, bool realistic,
loop->any_estimate = true; loop->any_estimate = true;
loop->nb_iterations_estimate = i_bound; loop->nb_iterations_estimate = i_bound;
} }
/* If an upper bound is smaller than the realistic estimate of the
number of iterations, use the upper bound instead. */
if (loop->any_upper_bound
&& loop->any_estimate
&& double_int_ucmp (loop->nb_iterations_upper_bound,
loop->nb_iterations_estimate) < 0)
loop->nb_iterations_estimate = loop->nb_iterations_upper_bound;
} }
/* Records that AT_STMT is executed at most BOUND + 1 times in LOOP. IS_EXIT /* Records that AT_STMT is executed at most BOUND + 1 times in LOOP. IS_EXIT
...@@ -2962,8 +2970,9 @@ estimate_numbers_of_iterations_loop (struct loop *loop) ...@@ -2962,8 +2970,9 @@ estimate_numbers_of_iterations_loop (struct loop *loop)
/* Give up if we already have tried to compute an estimation. */ /* Give up if we already have tried to compute an estimation. */
if (loop->estimate_state != EST_NOT_COMPUTED) if (loop->estimate_state != EST_NOT_COMPUTED)
return; return;
loop->estimate_state = EST_AVAILABLE; loop->estimate_state = EST_AVAILABLE;
loop->any_upper_bound = false; /* Force estimate compuation but leave any existing upper bound in place. */
loop->any_estimate = false; loop->any_estimate = false;
exits = get_loop_exit_edges (loop); exits = get_loop_exit_edges (loop);
...@@ -2994,14 +3003,6 @@ estimate_numbers_of_iterations_loop (struct loop *loop) ...@@ -2994,14 +3003,6 @@ estimate_numbers_of_iterations_loop (struct loop *loop)
bound = gcov_type_to_double_int (nit); bound = gcov_type_to_double_int (nit);
record_niter_bound (loop, bound, true, false); record_niter_bound (loop, bound, true, false);
} }
/* If an upper bound is smaller than the realistic estimate of the
number of iterations, use the upper bound instead. */
if (loop->any_upper_bound
&& loop->any_estimate
&& double_int_ucmp (loop->nb_iterations_upper_bound,
loop->nb_iterations_estimate) < 0)
loop->nb_iterations_estimate = loop->nb_iterations_upper_bound;
} }
/* Sets NIT to the estimated number of executions of the latch of the /* Sets NIT to the estimated number of executions of the latch of the
......
...@@ -2167,6 +2167,7 @@ vect_do_peeling_for_alignment (loop_vec_info loop_vinfo) ...@@ -2167,6 +2167,7 @@ vect_do_peeling_for_alignment (loop_vec_info loop_vinfo)
struct loop *new_loop; struct loop *new_loop;
unsigned int th = 0; unsigned int th = 0;
int min_profitable_iters; int min_profitable_iters;
int max_iter;
if (vect_print_dump_info (REPORT_DETAILS)) if (vect_print_dump_info (REPORT_DETAILS))
fprintf (vect_dump, "=== vect_do_peeling_for_alignment ==="); fprintf (vect_dump, "=== vect_do_peeling_for_alignment ===");
...@@ -2192,6 +2193,11 @@ vect_do_peeling_for_alignment (loop_vec_info loop_vinfo) ...@@ -2192,6 +2193,11 @@ vect_do_peeling_for_alignment (loop_vec_info loop_vinfo)
#ifdef ENABLE_CHECKING #ifdef ENABLE_CHECKING
slpeel_verify_cfg_after_peeling (new_loop, loop); slpeel_verify_cfg_after_peeling (new_loop, loop);
#endif #endif
max_iter = MAX (LOOP_VINFO_VECT_FACTOR (loop_vinfo) - 1, (int) th);
record_niter_bound (new_loop, shwi_to_double_int (max_iter), false, true);
if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file, "Setting upper bound of nb iterations for prologue "
"loop to %d\n", max_iter);
/* Update number of times loop executes. */ /* Update number of times loop executes. */
n_iters = LOOP_VINFO_NITERS (loop_vinfo); n_iters = LOOP_VINFO_NITERS (loop_vinfo);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment