summaryrefslogtreecommitdiff
path: root/gcc/predict.c
diff options
context:
space:
mode:
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2002-10-17 13:54:32 +0000
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2002-10-17 13:54:32 +0000
commit1a12dac499f7d59da972a7b941f4a839c848df87 (patch)
treeeec33f64b6ca8a24f1836169b02e799c86f22c09 /gcc/predict.c
parent149919c6ea55b51c2b97df0321c02bdbf673a954 (diff)
downloadgcc-1a12dac499f7d59da972a7b941f4a839c848df87.tar.gz
Really commit patch announced at Oct 14
PR c/7344 * predict.c (can_predict_insn_p): New function. (estimate_probability): Avoid unnecesary work. (process_note_prediction): Likewise. * toplev.c (rest_of_compilation): Account early branch prediction pass as TV_BRANCH_PROB. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@58246 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/predict.c')
-rw-r--r--gcc/predict.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/gcc/predict.c b/gcc/predict.c
index 844366aeeff..7e581468dec 100644
--- a/gcc/predict.c
+++ b/gcc/predict.c
@@ -80,6 +80,7 @@ static void process_note_prediction PARAMS ((basic_block, int *,
static bool last_basic_block_p PARAMS ((basic_block));
static void compute_function_frequency PARAMS ((void));
static void choose_function_section PARAMS ((void));
+static bool can_predict_insn_p PARAMS ((rtx));
/* Information we hold about each branch predictor.
Filled using information from predict.def. */
@@ -230,6 +231,18 @@ predict_edge (e, predictor, probability)
predict_insn (last_insn, predictor, probability);
}
+/* Return true when we can store prediction on insn INSN.
+ At the moment we represent predictions only on conditional
+ jumps, not at computed jump or other complicated cases. */
+static bool
+can_predict_insn_p (insn)
+ rtx insn;
+{
+ return (GET_CODE (insn) == JUMP_INSN
+ && any_condjump_p (insn)
+ && BLOCK_FOR_INSN (insn)->succ->succ_next);
+}
+
/* Predict edge E by given predictor if possible. */
void
@@ -440,7 +453,8 @@ estimate_probability (loops_info)
statements construct loops via "non-loop" constructs
in the source language and are better to be handled
separately. */
- if (predicted_by_p (bb, PRED_CONTINUE))
+ if (!can_predict_insn_p (bb->end)
+ || predicted_by_p (bb, PRED_CONTINUE))
continue;
/* Loop branch heuristics - predict an edge back to a
@@ -474,7 +488,7 @@ estimate_probability (loops_info)
rtx cond, earliest;
edge e;
- if (GET_CODE (last_insn) != JUMP_INSN || ! any_condjump_p (last_insn))
+ if (! can_predict_insn_p (last_insn))
continue;
for (e = bb->succ; e; e = e->succ_next)
@@ -763,7 +777,7 @@ process_note_prediction (bb, heads, dominators, post_dominators, pred, flags)
/* Now find the edge that leads to our branch and aply the prediction. */
- if (y == last_basic_block)
+ if (y == last_basic_block || !can_predict_insn_p (BASIC_BLOCK (y)->end))
return;
for (e = BASIC_BLOCK (y)->succ; e; e = e->succ_next)
if (e->dest->index >= 0
@@ -1148,9 +1162,7 @@ estimate_bb_frequencies (loops)
{
rtx last_insn = bb->end;
- if (GET_CODE (last_insn) != JUMP_INSN || !any_condjump_p (last_insn)
- /* Avoid handling of conditional jumps jumping to fallthru edge. */
- || bb->succ->succ_next == NULL)
+ if (!can_predict_insn_p (last_insn))
{
/* We can predict only conditional jumps at the moment.
Expect each edge to be equally probable.