http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48189
Steven Bosscher <steven at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |steven at gcc dot gnu.org
--- Comment #3 from Steven Bosscher <steven at gcc dot gnu.org> 2011-04-10
13:33:30 UTC ---
I'd say probability is zero i.e. never executed, as a special case. Or if you
consider the edge always taken, then the probability should be
REG_BR_PROB_BASE.
But zero seems more consistent:
Index: predict.c
===================================================================
--- predict.c (revision 172225)
+++ predict.c (working copy)
@@ -988,7 +988,14 @@
else
continue;
- probability = ((REG_BR_PROB_BASE + nitercst / 2) / nitercst);
+ if (nitercst == 0 && predictor == PRED_LOOP_ITERATIONS)
+ /* If the prediction for number of iterations is zero, the exits
+ will never be taken. Only make this prediction if we are quite
+ sure that the loop will never roll, from analysis. */
+ probability = 0;
+ else
+ probability = ((REG_BR_PROB_BASE + nitercst / 2) / nitercst);
+
predict_edge (ex, predictor, probability);
}
VEC_free (edge, heap, exits);
Or maybe just not predict at all:
Index: predict.c
===================================================================
--- predict.c (revision 172225)
+++ predict.c (working copy)
@@ -988,6 +988,11 @@
else
continue;
+ /* If the prediction for number of iterations is zero, do not
+ predict the exit edges. */
+ if (nitercst == 0)
+ continue;
+
probability = ((REG_BR_PROB_BASE + nitercst / 2) / nitercst);
predict_edge (ex, predictor, probability);
}