This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Avoid random block reorderings
- To: gcc-patches at gcc dot gnu dot org
- Subject: Avoid random block reorderings
- From: Jeffrey A Law <law at cygnus dot com>
- Date: Thu, 04 May 2000 14:40:36 -0600
- Reply-To: law at cygnus dot com
This patch avoids "random" block reorderings when none of the static branch
predictors apply by selecting the next physical block (if such a block exists)
as the predicted successor.
* predict.c (estimate_probability): If no prediction was found, then
predict the successor that is the next physical block (if such a
successor exists).
Index: predict.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/predict.c,v
retrieving revision 1.9
diff -c -3 -p -r1.9 predict.c
*** predict.c 2000/05/04 17:58:40 1.9
--- predict.c 2000/05/04 20:35:42
*************** estimate_probability (loops_info)
*** 202,207 ****
--- 202,220 ----
break;
}
+ /* If one of the blocks already directly follows the current
+ block, then predict it as the taken path. This reduces
+ random block movement. */
+ for (e = BASIC_BLOCK (i)->succ; e; e = e->succ_next)
+ if (e->dest->index == i + 1)
+ {
+ if (e->flags & EDGE_FALLTHRU)
+ prob = 0;
+ else
+ prob = REG_BR_PROB_BASE;
+ goto emitnote;
+ }
+
/* If we havn't chosen something by now, predict 50-50. */
prob = REG_BR_PROB_BASE / 2;