Commit 152897b1 by Zack Weinberg Committed by Zack Weinberg

predict.c (estimate_probability): New heuristic...

	* predict.c (estimate_probability): New heuristic: if a jump
	branches around a block with no successors, predict it taken.
	Disentangle control flow.

From-SVN: r33308
parent 93bc735f
2000-04-21 Zack Weinberg <zack@wolery.cumb.org>
* predict.c (estimate_probability): New heuristic: if a jump
branches around a block with no successors, predict it taken.
Disentangle control flow.
2000-04-20 Richard Henderson <rth@cygnus.com> 2000-04-20 Richard Henderson <rth@cygnus.com>
* loop.c (emit_iv_add_mult): Revert last change. * loop.c (emit_iv_add_mult): Revert last change.
......
...@@ -104,18 +104,37 @@ estimate_probability (loops_info) ...@@ -104,18 +104,37 @@ estimate_probability (loops_info)
rtx last_insn = BLOCK_END (i); rtx last_insn = BLOCK_END (i);
rtx cond, earliest; rtx cond, earliest;
int prob = 0; int prob = 0;
edge e;
if (GET_CODE (last_insn) != JUMP_INSN if (GET_CODE (last_insn) != JUMP_INSN
|| ! condjump_p (last_insn) || simplejump_p (last_insn)) || ! condjump_p (last_insn) || simplejump_p (last_insn))
continue; continue;
if (find_reg_note (last_insn, REG_BR_PROB, 0))
continue;
cond = get_condition (last_insn, &earliest); cond = get_condition (last_insn, &earliest);
if (! cond) if (! cond)
continue; continue;
/* If the jump branches around a block with no successors,
predict it to be taken. */
prob = 0;
for (e = BASIC_BLOCK (i)->succ; e; e = e->succ_next)
if ((e->flags & EDGE_FALLTHRU) && e->dest->succ == NULL)
{
prob = REG_BR_PROB_BASE;
break;
}
if (prob)
{
REG_NOTES (last_insn)
= gen_rtx_EXPR_LIST (REG_BR_PROB, GEN_INT (prob),
REG_NOTES (last_insn));
continue;
}
/* Try "pointer heuristic." /* Try "pointer heuristic."
A comparison ptr == 0 is predicted as false. A comparison ptr == 0 is predicted as false.
Similarly, a comparison ptr1 == ptr2 is predicted as false. */ Similarly, a comparison ptr1 == ptr2 is predicted as false. */
prob = 0;
switch (GET_CODE (cond)) switch (GET_CODE (cond))
{ {
case EQ: case EQ:
...@@ -137,10 +156,13 @@ estimate_probability (loops_info) ...@@ -137,10 +156,13 @@ estimate_probability (loops_info)
default: default:
prob = 0; prob = 0;
} }
if (prob && ! find_reg_note (last_insn, REG_BR_PROB, 0)) if (prob)
{
REG_NOTES (last_insn) REG_NOTES (last_insn)
= gen_rtx_EXPR_LIST (REG_BR_PROB, GEN_INT (prob), = gen_rtx_EXPR_LIST (REG_BR_PROB, GEN_INT (prob),
REG_NOTES (last_insn)); REG_NOTES (last_insn));
continue;
}
/* Try "opcode heuristic." /* Try "opcode heuristic."
EQ tests are usually false and NE tests are usually true. Also, EQ tests are usually false and NE tests are usually true. Also,
...@@ -174,10 +196,9 @@ estimate_probability (loops_info) ...@@ -174,10 +196,9 @@ estimate_probability (loops_info)
default: default:
prob = 0; prob = 0;
} }
if (! find_reg_note (last_insn, REG_BR_PROB, 0)) REG_NOTES (last_insn)
REG_NOTES (last_insn) = gen_rtx_EXPR_LIST (REG_BR_PROB, GEN_INT (prob),
= gen_rtx_EXPR_LIST (REG_BR_PROB, GEN_INT (prob), REG_NOTES (last_insn));
REG_NOTES (last_insn));
} }
} }
......
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