Commit 2ffa9932 by Jan Hubicka Committed by Jan Hubicka

Really commit patch announced at Oct 14 PR c/7344

	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.

From-SVN: r58246
parent b216f69b
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> 2002-10-17 Richard Sandiford <rsandifo@redhat.com>
* config.gcc (mips*-*-*): Add OBJECT_FORMAT_ELF to $tm_defines * 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> ...@@ -147,13 +157,6 @@ Mon Oct 14 20:33:12 CEST 2002 Jan Hubicka <jh@suse.cz>
* xmmintrin.h (__m128i): Define as __v2di. * 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 PR c++/6419
(expand_expr): Use DECL_RTL_SET_P. (expand_expr): Use DECL_RTL_SET_P.
......
...@@ -80,6 +80,7 @@ static void process_note_prediction PARAMS ((basic_block, int *, ...@@ -80,6 +80,7 @@ static void process_note_prediction PARAMS ((basic_block, int *,
static bool last_basic_block_p PARAMS ((basic_block)); static bool last_basic_block_p PARAMS ((basic_block));
static void compute_function_frequency PARAMS ((void)); static void compute_function_frequency PARAMS ((void));
static void choose_function_section PARAMS ((void)); static void choose_function_section PARAMS ((void));
static bool can_predict_insn_p PARAMS ((rtx));
/* Information we hold about each branch predictor. /* Information we hold about each branch predictor.
Filled using information from predict.def. */ Filled using information from predict.def. */
...@@ -230,6 +231,18 @@ predict_edge (e, predictor, probability) ...@@ -230,6 +231,18 @@ predict_edge (e, predictor, probability)
predict_insn (last_insn, 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. */ /* Predict edge E by given predictor if possible. */
void void
...@@ -440,7 +453,8 @@ estimate_probability (loops_info) ...@@ -440,7 +453,8 @@ estimate_probability (loops_info)
statements construct loops via "non-loop" constructs statements construct loops via "non-loop" constructs
in the source language and are better to be handled in the source language and are better to be handled
separately. */ separately. */
if (predicted_by_p (bb, PRED_CONTINUE)) if (!can_predict_insn_p (bb->end)
|| predicted_by_p (bb, PRED_CONTINUE))
continue; continue;
/* Loop branch heuristics - predict an edge back to a /* Loop branch heuristics - predict an edge back to a
...@@ -474,7 +488,7 @@ estimate_probability (loops_info) ...@@ -474,7 +488,7 @@ estimate_probability (loops_info)
rtx cond, earliest; rtx cond, earliest;
edge e; edge e;
if (GET_CODE (last_insn) != JUMP_INSN || ! any_condjump_p (last_insn)) if (! can_predict_insn_p (last_insn))
continue; continue;
for (e = bb->succ; e; e = e->succ_next) for (e = bb->succ; e; e = e->succ_next)
...@@ -763,7 +777,7 @@ process_note_prediction (bb, heads, dominators, post_dominators, pred, flags) ...@@ -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. */ /* 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; return;
for (e = BASIC_BLOCK (y)->succ; e; e = e->succ_next) for (e = BASIC_BLOCK (y)->succ; e; e = e->succ_next)
if (e->dest->index >= 0 if (e->dest->index >= 0
...@@ -1148,9 +1162,7 @@ estimate_bb_frequencies (loops) ...@@ -1148,9 +1162,7 @@ estimate_bb_frequencies (loops)
{ {
rtx last_insn = bb->end; rtx last_insn = bb->end;
if (GET_CODE (last_insn) != JUMP_INSN || !any_condjump_p (last_insn) if (!can_predict_insn_p (last_insn))
/* Avoid handling of conditional jumps jumping to fallthru edge. */
|| bb->succ->succ_next == NULL)
{ {
/* We can predict only conditional jumps at the moment. /* We can predict only conditional jumps at the moment.
Expect each edge to be equally probable. Expect each edge to be equally probable.
......
...@@ -2590,7 +2590,9 @@ rest_of_compilation (decl) ...@@ -2590,7 +2590,9 @@ rest_of_compilation (decl)
delete_unreachable_blocks (); delete_unreachable_blocks ();
/* Turn NOTE_INSN_PREDICTIONs into branch predictions. */ /* Turn NOTE_INSN_PREDICTIONs into branch predictions. */
timevar_push (TV_BRANCH_PROB);
note_prediction_to_br_prob (); note_prediction_to_br_prob ();
timevar_pop (TV_BRANCH_PROB);
/* We may have potential sibling or tail recursion sites. Select one /* We may have potential sibling or tail recursion sites. Select one
(of possibly multiple) methods of performing the call. */ (of possibly multiple) methods of performing the call. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment