Handle loops with loop->latch == NULL (PR gcov-profile/71868)

PR gcov-profile/71868
	* cfgloopanal.c (expected_loop_iterations_unbounded): When we
	have a function with multiple latches, count them all.

From-SVN: r238706
This commit is contained in:
Martin Liska 2016-07-25 12:56:08 +02:00 committed by Martin Liska
parent ccae0c8546
commit c1e1a688fb
2 changed files with 9 additions and 3 deletions

View file

@ -1,3 +1,9 @@
2016-07-25 Martin Liska <mliska@suse.cz>
PR gcov-profile/71868
* cfgloopanal.c (expected_loop_iterations_unbounded): When we
have a function with multiple latches, count them all.
2016-07-25 Martin Liska <mliska@suse.cz>
* tree-ssa-loop-niter.c (loop_only_exit_p): Release body array.

View file

@ -244,7 +244,7 @@ expected_loop_iterations_unbounded (const struct loop *loop,
/* If we have no profile at all, use AVG_LOOP_NITER. */
if (profile_status_for_fn (cfun) == PROFILE_ABSENT)
expected = PARAM_VALUE (PARAM_AVG_LOOP_NITER);
else if (loop->latch->count || loop->header->count)
else if (loop->latch && (loop->latch->count || loop->header->count))
{
gcov_type count_in, count_latch;
@ -274,8 +274,8 @@ expected_loop_iterations_unbounded (const struct loop *loop,
freq_latch = 0;
FOR_EACH_EDGE (e, ei, loop->header->preds)
if (e->src == loop->latch)
freq_latch = EDGE_FREQUENCY (e);
if (flow_bb_inside_loop_p (loop, e->src))
freq_latch += EDGE_FREQUENCY (e);
else
freq_in += EDGE_FREQUENCY (e);