I observed the odd looking code while looking into something else and confirmed prior behavior (before r248863) was to sum the counts of the non-latch predecessors of the loop (in order to scale the loop such that it no longer appears to iterate).
Bootstrap/regtest on powerpc64le with no regressions. Committed as obvious. -Pat 2018-10-31 Pat Haugen <pthau...@us.ibm.com> * tree-ssa-loop-ivcanon.c (try_peel_loop): Fix typo and remove dead initialization. Index: gcc/tree-ssa-loop-ivcanon.c =================================================================== --- gcc/tree-ssa-loop-ivcanon.c (revision 264821) +++ gcc/tree-ssa-loop-ivcanon.c (working copy) @@ -1139,10 +1139,10 @@ try_peel_loop (struct loop *loop, if (e->src != loop->latch) { if (e->src->count.initialized_p ()) - entry_count = e->src->count + e->src->count; + entry_count += e->src->count; gcc_assert (!flow_bb_inside_loop_p (loop, e->src)); } - profile_probability p = profile_probability::very_unlikely (); + profile_probability p; p = entry_count.probability_in (loop->header->count); scale_loop_profile (loop, p, 0); bitmap_set_bit (peeled_loops, loop->num);