Hi. As discussed with Honza, we should sum all edge frequencies when a loop has multiple latches.
Patch can bootstrap on ppc64le-redhat-linux and survives regression tests. Ready to be installed? Martin
>From 07dc9092511aedfe2786630d72419b16ef660d0c Mon Sep 17 00:00:00 2001 From: marxin <mli...@suse.cz> Date: Fri, 22 Jul 2016 11:36:52 +0200 Subject: [PATCH] Handle loops with loop->latch == NULL (PR gcov-profile/71868) gcc/ChangeLog: 2016-07-22 Martin Liska <mli...@suse.cz> PR gcov-profile/71868 * cfgloopanal.c (expected_loop_iterations_unbounded): When we have a function with multiple latches, count them all. --- gcc/cfgloopanal.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gcc/cfgloopanal.c b/gcc/cfgloopanal.c index 2739f44..ae08108 100644 --- a/gcc/cfgloopanal.c +++ b/gcc/cfgloopanal.c @@ -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,9 @@ 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 (e->src == loop->latch + || flow_bb_inside_loop_p (loop, e->src)) + freq_latch += EDGE_FREQUENCY (e); else freq_in += EDGE_FREQUENCY (e); -- 2.9.0