aboutsummaryrefslogtreecommitdiff
path: root/gcc/predict.c
diff options
context:
space:
mode:
authorJan Hubicka <hubicka@ucw.cz>2017-06-06 10:07:31 +0200
committerJan Hubicka <hubicka@gcc.gnu.org>2017-06-06 08:07:31 +0000
commit52261a21e8e74b98a943b2e9de1b9bef659bb28f (patch)
treef665b1228f58eeb2c1de5f21abf8a0c865ad3f74 /gcc/predict.c
parentce6ec23497cbe4cbac8165b927deaba220a523d8 (diff)
downloadgcc-52261a21e8e74b98a943b2e9de1b9bef659bb28f.zip
gcc-52261a21e8e74b98a943b2e9de1b9bef659bb28f.tar.gz
gcc-52261a21e8e74b98a943b2e9de1b9bef659bb28f.tar.bz2
predict.c (tree_estimate_probability_bb): Add LOCAL_ONLY.
* predict.c (tree_estimate_probability_bb): Add LOCAL_ONLY. (tree_guess_outgoing_edge_probabilities): New. * predict.h (tree_guess_outgoing_edge_probabilities): Declare. * tree-cfg.c (gimple_find_sub_bbs): Propagate profile. From-SVN: r248912
Diffstat (limited to 'gcc/predict.c')
-rw-r--r--gcc/predict.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/gcc/predict.c b/gcc/predict.c
index 8eb2863..2dbe3af 100644
--- a/gcc/predict.c
+++ b/gcc/predict.c
@@ -2665,10 +2665,11 @@ assert_is_empty (const_basic_block const &, edge_prediction *const &value,
return false;
}
-/* Predict branch probabilities and estimate profile for basic block BB. */
+/* Predict branch probabilities and estimate profile for basic block BB.
+ When LOCAL_ONLY is set do not use any global properties of CFG. */
static void
-tree_estimate_probability_bb (basic_block bb)
+tree_estimate_probability_bb (basic_block bb, bool local_only)
{
edge e;
edge_iterator ei;
@@ -2742,6 +2743,7 @@ tree_estimate_probability_bb (basic_block bb)
/* Look for block we are guarding (ie we dominate it,
but it doesn't postdominate us). */
if (e->dest != EXIT_BLOCK_PTR_FOR_FN (cfun) && e->dest != bb
+ && !local_only
&& dominated_by_p (CDI_DOMINATORS, e->dest, e->src)
&& !dominated_by_p (CDI_POST_DOMINATORS, e->src, e->dest))
{
@@ -2800,7 +2802,7 @@ tree_estimate_probability (bool dry_run)
predict_loops ();
FOR_EACH_BB_FN (bb, cfun)
- tree_estimate_probability_bb (bb);
+ tree_estimate_probability_bb (bb, false);
FOR_EACH_BB_FN (bb, cfun)
combine_predictions_for_bb (bb, dry_run);
@@ -2816,6 +2818,19 @@ tree_estimate_probability (bool dry_run)
free_dominance_info (CDI_POST_DOMINATORS);
remove_fake_exit_edges ();
}
+
+/* Set edge->probability for each successor edge of BB. */
+void
+tree_guess_outgoing_edge_probabilities (basic_block bb)
+{
+ bb_predictions = new hash_map<const_basic_block, edge_prediction *>;
+ tree_estimate_probability_bb (bb, true);
+ combine_predictions_for_bb (bb, false);
+ if (flag_checking)
+ bb_predictions->traverse<void *, assert_is_empty> (NULL);
+ delete bb_predictions;
+ bb_predictions = NULL;
+}
/* Predict edges to successors of CUR whose sources are not postdominated by
BB by PRED and recurse to all postdominators. */