Commit 97c53806 by Jan Hubicka Committed by Jan Hubicka

cfgloop.h (expected_loop_iterations_unbounded, [...]): Unconstify.


	* cfgloop.h (expected_loop_iterations_unbounded,
	expected_loop_iterations): Unconstify.
	* cfgloopanal.c (expected_loop_iterations_unbounded): Sanity check the
	profile with known upper bound; return 3 when profile is absent.
	(expected_loop_iterations): Update.

From-SVN: r236511
parent 216e8374
2016-05-20 Jan Hubicka <hubicka@ucw.cz> 2016-05-20 Jan Hubicka <hubicka@ucw.cz>
* cfgloop.h (expected_loop_iterations_unbounded,
expected_loop_iterations): Unconstify.
* cfgloopanal.c (expected_loop_iterations_unbounded): Sanity check the
profile with known upper bound; return 3 when profile is absent.
(expected_loop_iterations): Update.
2016-05-20 Jan Hubicka <hubicka@ucw.cz>
* loop-doloop.c (doloop_optimize): Use get_estimated_loop_iterations_int * loop-doloop.c (doloop_optimize): Use get_estimated_loop_iterations_int
and get_max_loop_iterations_int. and get_max_loop_iterations_int.
......
...@@ -316,8 +316,8 @@ extern void verify_loop_structure (void); ...@@ -316,8 +316,8 @@ extern void verify_loop_structure (void);
/* Loop analysis. */ /* Loop analysis. */
extern bool just_once_each_iteration_p (const struct loop *, const_basic_block); extern bool just_once_each_iteration_p (const struct loop *, const_basic_block);
gcov_type expected_loop_iterations_unbounded (const struct loop *); gcov_type expected_loop_iterations_unbounded (struct loop *);
extern unsigned expected_loop_iterations (const struct loop *); extern unsigned expected_loop_iterations (struct loop *);
extern rtx doloop_condition_get (rtx); extern rtx doloop_condition_get (rtx);
void mark_loop_for_removal (loop_p); void mark_loop_for_removal (loop_p);
......
...@@ -231,14 +231,20 @@ average_num_loop_insns (const struct loop *loop) ...@@ -231,14 +231,20 @@ average_num_loop_insns (const struct loop *loop)
value. */ value. */
gcov_type gcov_type
expected_loop_iterations_unbounded (const struct loop *loop) expected_loop_iterations_unbounded (struct loop *loop)
{ {
edge e; edge e;
edge_iterator ei; edge_iterator ei;
gcov_type expected;
if (loop->latch->count || loop->header->count)
/* Average loop rolls about 3 times. If we have no profile at all, it is
best we can do. */
if (profile_status_for_fn (cfun) == PROFILE_ABSENT)
expected = 3;
else if (loop->latch->count || loop->header->count)
{ {
gcov_type count_in, count_latch, expected; gcov_type count_in, count_latch;
count_in = 0; count_in = 0;
count_latch = 0; count_latch = 0;
...@@ -253,8 +259,6 @@ expected_loop_iterations_unbounded (const struct loop *loop) ...@@ -253,8 +259,6 @@ expected_loop_iterations_unbounded (const struct loop *loop)
expected = count_latch * 2; expected = count_latch * 2;
else else
expected = (count_latch + count_in - 1) / count_in; expected = (count_latch + count_in - 1) / count_in;
return expected;
} }
else else
{ {
...@@ -270,17 +274,28 @@ expected_loop_iterations_unbounded (const struct loop *loop) ...@@ -270,17 +274,28 @@ expected_loop_iterations_unbounded (const struct loop *loop)
freq_in += EDGE_FREQUENCY (e); freq_in += EDGE_FREQUENCY (e);
if (freq_in == 0) if (freq_in == 0)
return freq_latch * 2; {
/* If we have no profile at all, expect 3 iterations. */
return (freq_latch + freq_in - 1) / freq_in; if (!freq_latch)
expected = 3;
else
expected = freq_latch * 2;
}
else
expected = (freq_latch + freq_in - 1) / freq_in;
} }
HOST_WIDE_INT max = get_max_loop_iterations_int (loop);
if (max != -1 && max < expected)
return max;
return expected;
} }
/* Returns expected number of LOOP iterations. The returned value is bounded /* Returns expected number of LOOP iterations. The returned value is bounded
by REG_BR_PROB_BASE. */ by REG_BR_PROB_BASE. */
unsigned unsigned
expected_loop_iterations (const struct loop *loop) expected_loop_iterations (struct loop *loop)
{ {
gcov_type expected = expected_loop_iterations_unbounded (loop); gcov_type expected = expected_loop_iterations_unbounded (loop);
return (expected > REG_BR_PROB_BASE ? REG_BR_PROB_BASE : expected); return (expected > REG_BR_PROB_BASE ? REG_BR_PROB_BASE : expected);
......
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