+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
* 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.
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. */
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
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
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)
/* 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
{
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.
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. */