diff options
author | Jan Hubicka <jh@suse.cz> | 2005-10-31 15:48:57 +0100 |
---|---|---|
committer | Jan Hubicka <hubicka@gcc.gnu.org> | 2005-10-31 14:48:57 +0000 |
commit | f372b26ff875096812299e386ab15e6afbea8de3 (patch) | |
tree | ccb62239319136a6317c794f1949a20d9bf8f1af | |
parent | 52f661769db6a829a8537f1b8884646c99c5da5a (diff) | |
download | gcc-f372b26ff875096812299e386ab15e6afbea8de3.zip gcc-f372b26ff875096812299e386ab15e6afbea8de3.tar.gz gcc-f372b26ff875096812299e386ab15e6afbea8de3.tar.bz2 |
re PR gcov-profile/24487 (Basic block frequencies inaccurate)
PR profile/24487
* predict.c (predict_loops): Do not estimate more than
MAX_PRED_LOOP_ITERATIONS in PRED_LOOP_ITERATIONS heuristic.
* predict.def (MAX_PRED_LOOP_ITERATIONS): Define.
From-SVN: r106276
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/predict.c | 11 | ||||
-rw-r--r-- | gcc/predict.def | 12 |
3 files changed, 27 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2f77e79..aed0155 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2005-10-31 Jan Hubicka <jh@suse.cz> + + PR profile/24487 + * predict.c (predict_loops): Do not estimate more than + MAX_PRED_LOOP_ITERATIONS in PRED_LOOP_ITERATIONS heuristic. + * predict.def (MAX_PRED_LOOP_ITERATIONS): Define. + 2005-10-31 Andrew MacLeod <amacleod@redhat.com> PR tree-optimization/19097 diff --git a/gcc/predict.c b/gcc/predict.c index 412af86..e2f7262 100644 --- a/gcc/predict.c +++ b/gcc/predict.c @@ -624,6 +624,8 @@ predict_loops (struct loops *loops_info, bool rtlsimpleloops) niter = desc.niter + 1; if (niter == 0) /* We might overflow here. */ niter = desc.niter; + if (niter > MAX_PRED_LOOP_ITERATIONS) + niter = MAX_PRED_LOOP_ITERATIONS; prob = (REG_BR_PROB_BASE - (REG_BR_PROB_BASE + niter /2) / niter); @@ -654,13 +656,16 @@ predict_loops (struct loops *loops_info, bool rtlsimpleloops) if (host_integerp (niter, 1) && tree_int_cst_lt (niter, build_int_cstu (NULL_TREE, - REG_BR_PROB_BASE - 1))) + MAX_PRED_LOOP_ITERATIONS - 1))) { HOST_WIDE_INT nitercst = tree_low_cst (niter, 1) + 1; - probability = (REG_BR_PROB_BASE + nitercst / 2) / nitercst; + probability = ((REG_BR_PROB_BASE + nitercst / 2) + / nitercst); } else - probability = 1; + probability = ((REG_BR_PROB_BASE + + MAX_PRED_LOOP_ITERATIONS / 2) + / MAX_PRED_LOOP_ITERATIONS); predict_edge (exits[j], PRED_LOOP_ITERATIONS, probability); } diff --git a/gcc/predict.def b/gcc/predict.def index 997f4d2..fefe2ed 100644 --- a/gcc/predict.def +++ b/gcc/predict.def @@ -58,6 +58,18 @@ DEF_PREDICTOR (PRED_UNCONDITIONAL, "unconditional jump", PROB_ALWAYS, DEF_PREDICTOR (PRED_LOOP_ITERATIONS, "loop iterations", PROB_ALWAYS, PRED_FLAG_FIRST_MATCH) +/* For guessed profiles, the loops having unknown number of iterations + are predicted to iterate relatively few (10) times at average. + For functions containing one loop with large known number of iterations + and other loops having unbounded loops we would end up predicting all + the other loops cold that is not usually the case. So we need to artifically + flatten the profile. + + We need to cut the maximal predicted iterations to large enought iterations + so the loop appears important, but safely within HOT_BB_COUNT_FRACTION + range. */ +#define MAX_PRED_LOOP_ITERATIONS 100 + /* Hints dropped by user via __builtin_expect feature. */ DEF_PREDICTOR (PRED_BUILTIN_EXPECT, "__builtin_expect", PROB_VERY_LIKELY, PRED_FLAG_FIRST_MATCH) |