diff options
author | Jan Hubicka <hubicka@ucw.cz> | 2017-07-18 15:49:30 +0200 |
---|---|---|
committer | Jan Hubicka <hubicka@gcc.gnu.org> | 2017-07-18 13:49:30 +0000 |
commit | 33e9feb53082ee79d5f4321bcedf025f1bbd691d (patch) | |
tree | 57c3c850bc4efb6a3e987bff4d868699cf4fb069 /gcc | |
parent | ff22eb1256b05c1d0e0cf4b4b3114808bbf29457 (diff) | |
download | gcc-33e9feb53082ee79d5f4321bcedf025f1bbd691d.zip gcc-33e9feb53082ee79d5f4321bcedf025f1bbd691d.tar.gz gcc-33e9feb53082ee79d5f4321bcedf025f1bbd691d.tar.bz2 |
re PR tree-optimization/81462 (ICE in estimate_bb_frequencies at gcc/predict.c:3546)
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.
From-SVN: r250310
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/predict.c | 26 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/torture/pr81462.C | 17 |
4 files changed, 47 insertions, 8 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1d11ab5..892c025 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2017-07-18 Jan Hubicka <hubicka@ucw.cz> + + 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. + 2017-07-18 Nathan Sidwell <nathan@acm.org> * tree-parloops.c (try_transform_to_exit_first_loop_alt): Use diff --git a/gcc/predict.c b/gcc/predict.c index 310d9b0..1e2e11d 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) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 91aa26c..01f24ab 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-07-18 Jan Hubicka <hubicka@ucw.cz> + + PR middle-end/81462 + * g++.dg/torture/pr81462.C: New testcase. + 2017-07-18 Bin Cheng <bin.cheng@arm.com> PR target/81408 diff --git a/gcc/testsuite/g++.dg/torture/pr81462.C b/gcc/testsuite/g++.dg/torture/pr81462.C new file mode 100644 index 0000000..044c8b7 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr81462.C @@ -0,0 +1,17 @@ +// { dg-do compile } +// { dg-options "-O1 -fno-ipa-pure-const" } +struct B { + B* self; + B() : self( this ) { self->f(); } + virtual void f() = 0; + }; + + struct D : B + { + void f() {} + }; + + int main() + { + D d; + } |