This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Patch: incremental addition for static prediction
- To: gcc-patches at gcc dot gnu dot org
- Subject: Patch: incremental addition for static prediction
- From: Jason Eckhardt <jle at cygnus dot com>
- Date: Sun, 20 Feb 2000 17:56:30 -0800 (PST)
this patch adds another heuristic to static branch predictors for block
reordering. x86 bootstrap good, torture good.
acceptable?
* predict.c (estimate_probability): Added the pointer heuristic to
the collection of static branch predictors.
Index: predict.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/predict.c,v
retrieving revision 1.2
diff -c -3 -p -r1.2 predict.c
*** predict.c 2000/01/29 01:41:22 1.2
--- predict.c 2000/02/21 01:48:19
*************** estimate_probability (loops_info)
*** 95,101 ****
}
}
! /* Try to predict condjumps using same algorithm as mostly_true_jump. */
for (i = 0; i < n_basic_blocks - 1; i++)
{
rtx last_insn = BLOCK_END (i);
--- 95,104 ----
}
}
! /* 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);
*************** estimate_probability (loops_info)
*** 108,114 ****
cond = get_condition (last_insn, &earliest);
if (! cond)
continue;
! /* 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))
--- 111,153 ----
cond = get_condition (last_insn, &earliest);
if (! cond)
continue;
!
! /* 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))