aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Eckhardt <jle@cygnus.com>2000-02-21 23:04:43 +0000
committerJason Eckhardt <jle@gcc.gnu.org>2000-02-21 23:04:43 +0000
commit24c3bf687d847ec0fadeae8157e01eb09453d94d (patch)
tree62edd0d21b621443e00532127c21eca708a5fe08 /gcc
parent1e387156a844a5c5a016d65bfe29e1cf0fd2ec64 (diff)
downloadgcc-24c3bf687d847ec0fadeae8157e01eb09453d94d.zip
gcc-24c3bf687d847ec0fadeae8157e01eb09453d94d.tar.gz
gcc-24c3bf687d847ec0fadeae8157e01eb09453d94d.tar.bz2
predict.c (estimate_probability): Added the pointer heuristic to the collection of static branch predictors.
* predict.c (estimate_probability): Added the pointer heuristic to the collection of static branch predictors. From-SVN: r32093
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/predict.c39
2 files changed, 42 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 3378818..f6e5897 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+Mon Feb 21 17:06:27 2000 Jason Eckhardt <jle@cygnus.com>
+
+ * predict.c (estimate_probability): Added the pointer heuristic to
+ the collection of static branch predictors.
+
2000-02-21 Catherine Moore <clm@cygnus.com>
* config/mips/mips.h (ASM_SPEC): Add -mfix700.
diff --git a/gcc/predict.c b/gcc/predict.c
index d8a588f..2cae39a 100644
--- a/gcc/predict.c
+++ b/gcc/predict.c
@@ -95,7 +95,10 @@ estimate_probability (loops_info)
}
}
- /* Try to predict condjumps using same algorithm as mostly_true_jump. */
+ /* Attempt to predict conditional jumps using a number of heuristics.
+ For each conditional jump, we try each heuristic in a fixed order.
+ If more than one heuristic applies to a particular branch, the first
+ is used as the prediction for the branch. */
for (i = 0; i < n_basic_blocks - 1; i++)
{
rtx last_insn = BLOCK_END (i);
@@ -108,7 +111,39 @@ estimate_probability (loops_info)
cond = get_condition (last_insn, &earliest);
if (! cond)
continue;
- /* EQ tests are usually false and NE tests are usually true. Also,
+
+ /* Try "pointer heuristic."
+ A comparison ptr == 0 is predicted as false.
+ Similarly, a comparison ptr1 == ptr2 is predicted as false. */
+ prob = 0;
+ switch (GET_CODE (cond))
+ {
+ case EQ:
+ if (GET_CODE (XEXP (cond, 0)) == REG
+ && REGNO_POINTER_FLAG (REGNO (XEXP (cond, 0)))
+ && (XEXP (cond, 1) == const0_rtx
+ || (GET_CODE (XEXP (cond, 1)) == REG
+ && REGNO_POINTER_FLAG (REGNO (XEXP (cond, 1))))))
+ prob = REG_BR_PROB_BASE / 10;
+ break;
+ case NE:
+ if (GET_CODE (XEXP (cond, 0)) == REG
+ && REGNO_POINTER_FLAG (REGNO (XEXP (cond, 0)))
+ && (XEXP (cond, 1) == const0_rtx
+ || (GET_CODE (XEXP (cond, 1)) == REG
+ && REGNO_POINTER_FLAG (REGNO (XEXP (cond, 1))))))
+ prob = REG_BR_PROB_BASE / 2;
+ break;
+ default:
+ prob = 0;
+ }
+ if (prob && ! find_reg_note (last_insn, REG_BR_PROB, 0))
+ REG_NOTES (last_insn)
+ = gen_rtx_EXPR_LIST (REG_BR_PROB, GEN_INT (prob),
+ REG_NOTES (last_insn));
+
+ /* Try "opcode heuristic."
+ 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 (cond))