Commit 33e9feb5 by Jan Hubicka Committed by Jan Hubicka

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
parent ff22eb12
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> 2017-07-18 Nathan Sidwell <nathan@acm.org>
* tree-parloops.c (try_transform_to_exit_first_loop_alt): Use * tree-parloops.c (try_transform_to_exit_first_loop_alt): Use
......
...@@ -817,16 +817,25 @@ static void ...@@ -817,16 +817,25 @@ static void
set_even_probabilities (basic_block bb, set_even_probabilities (basic_block bb,
hash_set<edge> *unlikely_edges = NULL) hash_set<edge> *unlikely_edges = NULL)
{ {
unsigned nedges = 0; unsigned nedges = 0, unlikely_count = 0;
edge e = NULL; edge e = NULL;
edge_iterator ei; edge_iterator ei;
profile_probability all = profile_probability::always ();
FOR_EACH_EDGE (e, ei, bb->succs) FOR_EACH_EDGE (e, ei, bb->succs)
if (!unlikely_executed_edge_p (e)) if (e->probability.initialized_p ())
nedges ++; 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. */ /* Make the distribution even if all edges are unlikely. */
unsigned unlikely_count = unlikely_edges ? unlikely_edges->elements () : 0;
if (unlikely_count == nedges) if (unlikely_count == nedges)
{ {
unlikely_edges = NULL; unlikely_edges = NULL;
...@@ -836,13 +845,14 @@ set_even_probabilities (basic_block bb, ...@@ -836,13 +845,14 @@ set_even_probabilities (basic_block bb,
unsigned c = nedges - unlikely_count; unsigned c = nedges - unlikely_count;
FOR_EACH_EDGE (e, ei, bb->succs) 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)) if (unlikely_edges != NULL && unlikely_edges->contains (e))
e->probability = profile_probability::very_unlikely (); e->probability = profile_probability::very_unlikely ();
else else
e->probability = profile_probability::guessed_always () e->probability = all.apply_scale (1, c).guessed ();
.apply_scale (1, c);
} }
else else
e->probability = profile_probability::never (); e->probability = profile_probability::never ();
...@@ -1151,7 +1161,7 @@ combine_predictions_for_bb (basic_block bb, bool dry_run) ...@@ -1151,7 +1161,7 @@ combine_predictions_for_bb (basic_block bb, bool dry_run)
if (pred->ep_probability <= PROB_VERY_UNLIKELY) if (pred->ep_probability <= PROB_VERY_UNLIKELY)
unlikely_edges.add (pred->ep_edge); unlikely_edges.add (pred->ep_edge);
if (!bb->count.initialized_p () && !dry_run) if (!dry_run)
set_even_probabilities (bb, &unlikely_edges); set_even_probabilities (bb, &unlikely_edges);
clear_bb_predictions (bb); clear_bb_predictions (bb);
if (dump_file) if (dump_file)
......
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> 2017-07-18 Bin Cheng <bin.cheng@arm.com>
PR target/81408 PR target/81408
......
// { 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;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment