summaryrefslogtreecommitdiff
path: root/gcc
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
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')
-rw-r--r--gcc/ChangeLog17
-rw-r--r--gcc/predict.c24
-rw-r--r--gcc/toplev.c2
3 files changed, 30 insertions, 13 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 5fb61e0c1fa..61175522871 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,13 @@
+Wed Oct 16 15:01:29 CEST 2002 Jan Hubicka <jh@suse.cz>
+
+ 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.
+
2002-10-17 Richard Sandiford <rsandifo@redhat.com>
* config.gcc (mips*-*-*): Add OBJECT_FORMAT_ELF to $tm_defines
@@ -147,13 +157,6 @@ Mon Oct 14 20:33:12 CEST 2002 Jan Hubicka <jh@suse.cz>
* xmmintrin.h (__m128i): Define as __v2di.
- 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.
-
PR c++/6419
(expand_expr): Use DECL_RTL_SET_P.
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.
diff --git a/gcc/toplev.c b/gcc/toplev.c
index a6fe726af81..21738982597 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -2590,7 +2590,9 @@ rest_of_compilation (decl)
delete_unreachable_blocks ();
/* Turn NOTE_INSN_PREDICTIONs into branch predictions. */
+ timevar_push (TV_BRANCH_PROB);
note_prediction_to_br_prob ();
+ timevar_pop (TV_BRANCH_PROB);
/* We may have potential sibling or tail recursion sites. Select one
(of possibly multiple) methods of performing the call. */