Commit 52ba2f6d by Steven Bosscher Committed by Steven Bosscher

reorg.c (mostly_true_jump): Clean up code depending on LABEL_OUTSIDE_LOOP_P and loop notes.

	* reorg.c (mostly_true_jump): Clean up code depending on
	LABEL_OUTSIDE_LOOP_P and loop notes.  Remove code doing
	poor man's branch prediction, instead rely on REG_BR_PROB
	notes to be available.

From-SVN: r108653
parent 5adb25cf
2005-12-16 Steven Bosscher <stevenb@suse.de>
* reorg.c (mostly_true_jump): Clean up code depending on
LABEL_OUTSIDE_LOOP_P and loop notes. Remove code doing
poor man's branch prediction, instead rely on REG_BR_PROB
notes to be available.
2005-12-16 Jakub Jelinek <jakub@redhat.com> 2005-12-16 Jakub Jelinek <jakub@redhat.com>
PR rtl-optimization/24899 PR rtl-optimization/24899
......
...@@ -964,8 +964,7 @@ mostly_true_jump (rtx jump_insn, rtx condition) ...@@ -964,8 +964,7 @@ mostly_true_jump (rtx jump_insn, rtx condition)
{ {
rtx target_label = JUMP_LABEL (jump_insn); rtx target_label = JUMP_LABEL (jump_insn);
rtx insn, note; rtx insn, note;
int rare_dest = rare_destination (target_label); int rare_dest, rare_fallthrough;
int rare_fallthrough = rare_destination (NEXT_INSN (jump_insn));
/* If branch probabilities are available, then use that number since it /* If branch probabilities are available, then use that number since it
always gives a correct answer. */ always gives a correct answer. */
...@@ -984,32 +983,10 @@ mostly_true_jump (rtx jump_insn, rtx condition) ...@@ -984,32 +983,10 @@ mostly_true_jump (rtx jump_insn, rtx condition)
return -1; return -1;
} }
/* ??? Ought to use estimate_probability instead. */
/* If this is a branch outside a loop, it is highly unlikely. */
if (GET_CODE (PATTERN (jump_insn)) == SET
&& GET_CODE (SET_SRC (PATTERN (jump_insn))) == IF_THEN_ELSE
&& ((GET_CODE (XEXP (SET_SRC (PATTERN (jump_insn)), 1)) == LABEL_REF
&& LABEL_OUTSIDE_LOOP_P (XEXP (SET_SRC (PATTERN (jump_insn)), 1)))
|| (GET_CODE (XEXP (SET_SRC (PATTERN (jump_insn)), 2)) == LABEL_REF
&& LABEL_OUTSIDE_LOOP_P (XEXP (SET_SRC (PATTERN (jump_insn)), 2)))))
return -1;
if (target_label)
{
/* If this is the test of a loop, it is very likely true. We scan
backwards from the target label. If we find a NOTE_INSN_LOOP_BEG
before the next real insn, we assume the branch is to the top of
the loop. */
for (insn = PREV_INSN (target_label);
insn && NOTE_P (insn);
insn = PREV_INSN (insn))
if (NOTE_LINE_NUMBER (insn) == NOTE_INSN_LOOP_BEG)
return 2;
}
/* Look at the relative rarities of the fallthrough and destination. If /* Look at the relative rarities of the fallthrough and destination. If
they differ, we can predict the branch that way. */ they differ, we can predict the branch that way. */
rare_dest = rare_destination (target_label);
rare_fallthrough = rare_destination (NEXT_INSN (jump_insn));
switch (rare_fallthrough - rare_dest) switch (rare_fallthrough - rare_dest)
{ {
...@@ -1030,33 +1007,6 @@ mostly_true_jump (rtx jump_insn, rtx condition) ...@@ -1030,33 +1007,6 @@ mostly_true_jump (rtx jump_insn, rtx condition)
if (condition == 0) if (condition == 0)
return 0; return 0;
/* EQ tests are usually false and NE tests are usually true. Also,
most quantities are positive, so we can make the appropriate guesses
about signed comparisons against zero. */
switch (GET_CODE (condition))
{
case CONST_INT:
/* Unconditional branch. */
return 1;
case EQ:
return 0;
case NE:
return 1;
case LE:
case LT:
if (XEXP (condition, 1) == const0_rtx)
return 0;
break;
case GE:
case GT:
if (XEXP (condition, 1) == const0_rtx)
return 1;
break;
default:
break;
}
/* Predict backward branches usually take, forward branches usually not. If /* Predict backward branches usually take, forward branches usually not. If
we don't know whether this is forward or backward, assume the branch we don't know whether this is forward or backward, assume the branch
will be taken, since most are. */ will be taken, since most are. */
......
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