diff options
Diffstat (limited to 'gcc/predict.c')
-rw-r--r-- | gcc/predict.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/gcc/predict.c b/gcc/predict.c index 412af8616e7..e2f7262f285 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); } |