diff options
author | Steven Bosscher <stevenb@suse.de> | 2005-12-16 15:38:19 +0000 |
---|---|---|
committer | Steven Bosscher <steven@gcc.gnu.org> | 2005-12-16 15:38:19 +0000 |
commit | 52ba2f6d147b5d36d5d812200f7cbede0803f7f1 (patch) | |
tree | c319077994161c5a5df9b44f54d22e7cf5199a43 | |
parent | 5adb25cf832a5e71551ed24fa6b2a3ba6f7a48f9 (diff) | |
download | gcc-52ba2f6d147b5d36d5d812200f7cbede0803f7f1.zip gcc-52ba2f6d147b5d36d5d812200f7cbede0803f7f1.tar.gz gcc-52ba2f6d147b5d36d5d812200f7cbede0803f7f1.tar.bz2 |
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
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/reorg.c | 56 |
2 files changed, 10 insertions, 53 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f5e91e6..a73bcb4 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +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> PR rtl-optimization/24899 diff --git a/gcc/reorg.c b/gcc/reorg.c index 46154f1..104ad8e 100644 --- a/gcc/reorg.c +++ b/gcc/reorg.c @@ -964,8 +964,7 @@ mostly_true_jump (rtx jump_insn, rtx condition) { rtx target_label = JUMP_LABEL (jump_insn); rtx insn, note; - int rare_dest = rare_destination (target_label); - int rare_fallthrough = rare_destination (NEXT_INSN (jump_insn)); + int rare_dest, rare_fallthrough; /* If branch probabilities are available, then use that number since it always gives a correct answer. */ @@ -984,32 +983,10 @@ mostly_true_jump (rtx jump_insn, rtx condition) 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 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) { @@ -1030,33 +1007,6 @@ mostly_true_jump (rtx jump_insn, rtx condition) if (condition == 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 we don't know whether this is forward or backward, assume the branch will be taken, since most are. */ |