summaryrefslogtreecommitdiff
path: root/gcc/predict.c
diff options
context:
space:
mode:
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2007-02-27 10:21:55 +0000
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2007-02-27 10:21:55 +0000
commitf657a7ae2d1fca5de9de8b5e2f78a25e57bbb935 (patch)
tree0c3c063ccfe36409185c4de1ed6e9da97d522e73 /gcc/predict.c
parent3a8843c6da5f76535c016db4d0c8da620a7cde3e (diff)
downloadgcc-f657a7ae2d1fca5de9de8b5e2f78a25e57bbb935.tar.gz
* predict.c (last_basic_block_p): Remove.
(tree_estimate_probability): Update return heuristic for commonized return blocks. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@122367 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/predict.c')
-rw-r--r--gcc/predict.c56
1 files changed, 31 insertions, 25 deletions
diff --git a/gcc/predict.c b/gcc/predict.c
index f390ebedb4d..349ab739140 100644
--- a/gcc/predict.c
+++ b/gcc/predict.c
@@ -75,7 +75,6 @@ static sreal real_zero, real_one, real_almost_one, real_br_prob_base,
static void combine_predictions_for_insn (rtx, basic_block);
static void dump_prediction (FILE *, enum br_predictor, int, basic_block, int);
static void predict_paths_leading_to (basic_block, int *, enum br_predictor, enum prediction);
-static bool last_basic_block_p (basic_block);
static void compute_function_frequency (void);
static void choose_function_section (void);
static bool can_predict_insn_p (rtx);
@@ -1290,20 +1289,41 @@ tree_estimate_probability (void)
{
/* Predict early returns to be probable, as we've already taken
care for error returns and other cases are often used for
- fast paths through function. */
- if (e->dest == EXIT_BLOCK_PTR
- && TREE_CODE (last_stmt (bb)) == RETURN_EXPR
- && !single_pred_p (bb))
+ fast paths through function.
+
+ Since we've already removed the return statments, we are
+ looking for CFG like:
+
+ if (conditoinal)
+ {
+ ..
+ goto return_block
+ }
+ some other blocks
+ return_block:
+ return_stmt. */
+ if (e->dest != bb->next_bb
+ && e->dest != EXIT_BLOCK_PTR
+ && single_succ_p (e->dest)
+ && single_succ_edge (e->dest)->dest == EXIT_BLOCK_PTR
+ && TREE_CODE (last_stmt (e->dest)) == RETURN_EXPR)
{
edge e1;
edge_iterator ei1;
- FOR_EACH_EDGE (e1, ei1, bb->preds)
- if (!predicted_by_p (e1->src, PRED_NULL_RETURN)
- && !predicted_by_p (e1->src, PRED_CONST_RETURN)
- && !predicted_by_p (e1->src, PRED_NEGATIVE_RETURN)
- && !last_basic_block_p (e1->src))
- predict_edge_def (e1, PRED_TREE_EARLY_RETURN, NOT_TAKEN);
+ if (single_succ_p (bb))
+ {
+ FOR_EACH_EDGE (e1, ei1, bb->preds)
+ if (!predicted_by_p (e1->src, PRED_NULL_RETURN)
+ && !predicted_by_p (e1->src, PRED_CONST_RETURN)
+ && !predicted_by_p (e1->src, PRED_NEGATIVE_RETURN))
+ predict_edge_def (e1, PRED_TREE_EARLY_RETURN, NOT_TAKEN);
+ }
+ else
+ if (!predicted_by_p (e->src, PRED_NULL_RETURN)
+ && !predicted_by_p (e->src, PRED_CONST_RETURN)
+ && !predicted_by_p (e->src, PRED_NEGATIVE_RETURN))
+ predict_edge_def (e, PRED_TREE_EARLY_RETURN, NOT_TAKEN);
}
/* Look for block we are guarding (ie we dominate it,
@@ -1353,20 +1373,6 @@ tree_estimate_probability (void)
return 0;
}
-/* Check whether this is the last basic block of function. Commonly
- there is one extra common cleanup block. */
-static bool
-last_basic_block_p (basic_block bb)
-{
- if (bb == EXIT_BLOCK_PTR)
- return false;
-
- return (bb->next_bb == EXIT_BLOCK_PTR
- || (bb->next_bb->next_bb == EXIT_BLOCK_PTR
- && single_succ_p (bb)
- && single_succ (bb)->next_bb == EXIT_BLOCK_PTR));
-}
-
/* Sets branch probabilities according to PREDiction and
FLAGS. HEADS[bb->index] should be index of basic block in that we
need to alter branch predictions (i.e. the first of our dominators