Hi, this is the last remaining case of integer scaling. The issue is again the same. We scale up which is not best idea and unrolling done via cfgloopmanip gets around wtihout doing it. Again I decided to keep the logic for now, just update it to profile counts.
Bootstrapped/regtested x86_64-linux, comitted. * tree-ssa-loop-manip.c (scale_dominated_blocks_in_loop): Update to profile counts. (tree_transform_and_unroll_loop): Likewise. Index: tree-ssa-loop-manip.c =================================================================== --- tree-ssa-loop-manip.c (revision 254767) +++ tree-ssa-loop-manip.c (working copy) @@ -1091,11 +1091,11 @@ determine_exit_conditions (struct loop * static void scale_dominated_blocks_in_loop (struct loop *loop, basic_block bb, - int num, int den) + profile_count num, profile_count den) { basic_block son; - if (den == 0) + if (!den.nonzero_p () && !(num == profile_count::zero ())) return; for (son = first_dom_son (CDI_DOMINATORS, bb); @@ -1104,7 +1104,7 @@ scale_dominated_blocks_in_loop (struct l { if (!flow_bb_inside_loop_p (loop, son)) continue; - scale_bbs_frequencies_int (&son, 1, num, den); + scale_bbs_frequencies_profile_count (&son, 1, num, den); scale_dominated_blocks_in_loop (loop, son, num, den); } } @@ -1281,9 +1281,10 @@ tree_transform_and_unroll_loop (struct l scale_dominated_blocks_in_loop (loop, exit->src, /* We are scaling up here so probability does not fit. */ - REG_BR_PROB_BASE, - REG_BR_PROB_BASE - - exit->probability.to_reg_br_prob_base ()); + loop->header->count, + loop->header->count + - loop->header->count.apply_probability + (exit->probability)); bsi = gsi_last_bb (exit_bb); exit_if = gimple_build_cond (EQ_EXPR, integer_zero_node, @@ -1377,8 +1378,7 @@ tree_transform_and_unroll_loop (struct l { /* Avoid dropping loop body profile counter to 0 because of zero count in loop's preheader. */ - if (freq_e == profile_count::zero ()) - freq_e = profile_count::from_gcov_type (1); + freq_e = freq_e.force_nonzero (); scale_loop_frequencies (loop, freq_e.probability_in (freq_h)); }