From 7ec47501cdce2313e8aeb0b3fae787257568d44c Mon Sep 17 00:00:00 2001 From: hubicka Date: Sun, 16 Jul 2017 18:25:26 +0000 Subject: [PATCH] * tree-ssa-loop-manip.c (tree_transform_and_unroll_loop): Use profile_proability for scalling. * scale_profile_for_vect_loop.c (scale_profile_for_vect_loop): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@250245 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 6 ++++++ gcc/tree-ssa-loop-manip.c | 35 ++++++++++++++--------------------- gcc/tree-vect-loop.c | 8 +++----- 3 files changed, 23 insertions(+), 26 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c6491ffa5b2..31979ed91b3 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,11 @@ 2017-07-16 Jan Hubicka + * tree-ssa-loop-manip.c (tree_transform_and_unroll_loop): Use + profile_proability for scalling. + * scale_profile_for_vect_loop.c (scale_profile_for_vect_loop): Likewise. + +2017-07-16 Jan Hubicka + * cgraph.c (cgraph_edge::redirect_call_stmt_to_caller): Cleanup. 2017-07-16 Jan Hubicka diff --git a/gcc/tree-ssa-loop-manip.c b/gcc/tree-ssa-loop-manip.c index b2f5f16b52a..5488044b18f 100644 --- a/gcc/tree-ssa-loop-manip.c +++ b/gcc/tree-ssa-loop-manip.c @@ -1212,7 +1212,8 @@ tree_transform_and_unroll_loop (struct loop *loop, unsigned factor, gimple_stmt_iterator bsi; use_operand_p op; bool ok; - unsigned i, prob, prob_entry, scale_unrolled; + unsigned i; + profile_probability prob, prob_entry, scale_unrolled; profile_count freq_e, freq_h; gcov_type new_est_niter = niter_for_unrolled_loop (loop, factor); unsigned irr = loop_preheader_edge (loop)->flags & EDGE_IRREDUCIBLE_LOOP; @@ -1224,9 +1225,10 @@ tree_transform_and_unroll_loop (struct loop *loop, unsigned factor, /* Let us assume that the unrolled loop is quite likely to be entered. */ if (integer_nonzerop (enter_main_cond)) - prob_entry = REG_BR_PROB_BASE; + prob_entry = profile_probability::always (); else - prob_entry = PROB_UNROLLED_LOOP_ENTERED * REG_BR_PROB_BASE / 100; + prob_entry = profile_probability::guessed_always () + .apply_scale (PROB_UNROLLED_LOOP_ENTERED, 100); /* The values for scales should keep profile consistent, and somewhat close to correct. @@ -1242,13 +1244,8 @@ tree_transform_and_unroll_loop (struct loop *loop, unsigned factor, by appropriate factors). */ scale_unrolled = prob_entry; - new_loop = loop_version (loop, enter_main_cond, NULL, - profile_probability::from_reg_br_prob_base - (prob_entry), - profile_probability::from_reg_br_prob_base - (REG_BR_PROB_BASE - prob_entry), - profile_probability::from_reg_br_prob_base - (scale_unrolled), + new_loop = loop_version (loop, enter_main_cond, NULL, prob_entry, + prob_entry.invert (), scale_unrolled, profile_probability::guessed_always (), true); gcc_assert (new_loop != NULL); @@ -1266,6 +1263,8 @@ tree_transform_and_unroll_loop (struct loop *loop, unsigned factor, 1 / (1 - exit->probability). */ if (exit->probability.initialized_p ()) 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 ()); @@ -1289,9 +1288,7 @@ tree_transform_and_unroll_loop (struct loop *loop, unsigned factor, new_nonexit->flags = EDGE_TRUE_VALUE; new_nonexit->count -= exit->count; if (new_nonexit->probability.initialized_p ()) - scale_bbs_frequencies_int (&loop->latch, 1, - new_nonexit->probability.to_reg_br_prob_base (), - REG_BR_PROB_BASE); + scale_bbs_frequencies (&loop->latch, 1, new_nonexit->probability); old_entry = loop_preheader_edge (loop); new_entry = loop_preheader_edge (new_loop); @@ -1388,16 +1385,12 @@ tree_transform_and_unroll_loop (struct loop *loop, unsigned factor, rest->frequency += EDGE_FREQUENCY (new_exit); new_nonexit = single_pred_edge (loop->latch); - if (new_nonexit->probability.initialized_p ()) - prob = new_nonexit->probability.to_reg_br_prob_base (); - else - prob = 0; + prob = new_nonexit->probability; new_nonexit->probability = new_exit->probability.invert (); new_nonexit->count = exit_bb->count - new_exit->count; - if (prob > 0) - scale_bbs_frequencies_int (&loop->latch, 1, - new_nonexit->probability.to_reg_br_prob_base (), - prob); + prob = new_nonexit->probability / prob; + if (prob.initialized_p ()) + scale_bbs_frequencies (&loop->latch, 1, prob); /* Finally create the new counter for number of iterations and add the new exit instruction. */ diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c index 8168f27080e..6c18c8f8ecb 100644 --- a/gcc/tree-vect-loop.c +++ b/gcc/tree-vect-loop.c @@ -7222,13 +7222,11 @@ scale_profile_for_vect_loop (struct loop *loop, unsigned vf) .apply_scale (1, new_est_niter + 1); edge exit_l = single_pred_edge (loop->latch); - int prob = exit_l->probability.initialized_p () - ? exit_l->probability.to_reg_br_prob_base () : 0; + profile_probability prob = exit_l->probability; exit_l->probability = exit_e->probability.invert (); exit_l->count = exit_bb->count - exit_e->count; - if (prob > 0) - scale_bbs_frequencies_int (&loop->latch, 1, - exit_l->probability.to_reg_br_prob_base (), prob); + if (prob.initialized_p () && exit_l->probability.initialized_p ()) + scale_bbs_frequencies (&loop->latch, 1, exit_l->probability / prob); } /* Function vect_transform_loop. -- 2.11.4.GIT