+2019-03-19 Martin Liska <mliska@suse.cz>
+
+ PR middle-end/89737
+ * predict.c (combine_predictions_for_bb): Empty likely_edges and
+ unlikely_edges if there's an edge that belongs to both these sets.
+
2018-03-19 Segher Boessenkool <segher@kernel.crashing.org>
PR target/89746
if (pred->ep_probability <= PROB_VERY_UNLIKELY
|| pred->ep_predictor == PRED_COLD_LABEL)
unlikely_edges.add (pred->ep_edge);
- if (pred->ep_probability >= PROB_VERY_LIKELY
- || pred->ep_predictor == PRED_BUILTIN_EXPECT
- || pred->ep_predictor == PRED_HOT_LABEL)
+ else if (pred->ep_probability >= PROB_VERY_LIKELY
+ || pred->ep_predictor == PRED_BUILTIN_EXPECT
+ || pred->ep_predictor == PRED_HOT_LABEL)
likely_edges.add (pred);
}
+ /* It can happen that an edge is both in likely_edges and unlikely_edges.
+ Clear both sets in that situation. */
+ for (hash_set<edge_prediction *>::iterator it = likely_edges.begin ();
+ it != likely_edges.end (); ++it)
+ if (unlikely_edges.contains ((*it)->ep_edge))
+ {
+ likely_edges.empty ();
+ unlikely_edges.empty ();
+ break;
+ }
+
if (!dry_run)
set_even_probabilities (bb, &unlikely_edges, &likely_edges);
clear_bb_predictions (bb);
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-profile_estimate" } */
+
+int a, b;
+
+void c() {
+ &&d;
+ void *e = &&f, *g = &&h;
+f:
+ __attribute__((hot)) h : __attribute__((cold)) for (; a;) goto *g;
+d:
+ for (; b;)
+ goto *e;
+}
+
+/* { dg-final { scan-tree-dump-times "predicted to even probabilities" 4 "profile_estimate"} } */
+