diff options
author | hubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4> | 2017-07-18 13:49:30 +0000 |
---|---|---|
committer | hubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4> | 2017-07-18 13:49:30 +0000 |
commit | c7a0aa224dbb257d57d7b68305b5936a189b2a74 (patch) | |
tree | 57c3c850bc4efb6a3e987bff4d868699cf4fb069 /gcc/predict.c | |
parent | a8de6c92c3d8face4414815d2e66d9e433b31db9 (diff) |
PR middle-end/81462
* predict.c (set_even_probabilities): Cleanup; do not affect
probabilities that are already known.
(combine_predictions_for_bb): Call even when count is set.
* g++.dg/torture/pr81462.C: New testcase.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@250310 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/predict.c')
-rw-r--r-- | gcc/predict.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/gcc/predict.c b/gcc/predict.c index 310d9b0aced..1e2e11d71f0 100644 --- a/gcc/predict.c +++ b/gcc/predict.c @@ -817,16 +817,25 @@ static void set_even_probabilities (basic_block bb, hash_set<edge> *unlikely_edges = NULL) { - unsigned nedges = 0; + unsigned nedges = 0, unlikely_count = 0; edge e = NULL; edge_iterator ei; + profile_probability all = profile_probability::always (); FOR_EACH_EDGE (e, ei, bb->succs) - if (!unlikely_executed_edge_p (e)) - nedges ++; + if (e->probability.initialized_p ()) + all -= e->probability; + else if (!unlikely_executed_edge_p (e)) + { + nedges ++; + if (unlikely_edges != NULL && unlikely_edges->contains (e)) + { + all -= profile_probability::very_unlikely (); + unlikely_count++; + } + } /* Make the distribution even if all edges are unlikely. */ - unsigned unlikely_count = unlikely_edges ? unlikely_edges->elements () : 0; if (unlikely_count == nedges) { unlikely_edges = NULL; @@ -836,13 +845,14 @@ set_even_probabilities (basic_block bb, unsigned c = nedges - unlikely_count; FOR_EACH_EDGE (e, ei, bb->succs) - if (!unlikely_executed_edge_p (e)) + if (e->probability.initialized_p ()) + ; + else if (!unlikely_executed_edge_p (e)) { if (unlikely_edges != NULL && unlikely_edges->contains (e)) e->probability = profile_probability::very_unlikely (); else - e->probability = profile_probability::guessed_always () - .apply_scale (1, c); + e->probability = all.apply_scale (1, c).guessed (); } else e->probability = profile_probability::never (); @@ -1151,7 +1161,7 @@ combine_predictions_for_bb (basic_block bb, bool dry_run) if (pred->ep_probability <= PROB_VERY_UNLIKELY) unlikely_edges.add (pred->ep_edge); - if (!bb->count.initialized_p () && !dry_run) + if (!dry_run) set_even_probabilities (bb, &unlikely_edges); clear_bb_predictions (bb); if (dump_file) |