Commit 6efcd268 by Jan Hubicka Committed by Jan Hubicka

* predict.c (estimate_probability): Fix roundoff error.

From-SVN: r62765
parent 9083b5da
Wed Feb 12 15:19:42 CET 2003 Jan Hubicka <jh@suse.cz>
* predict.c (estimate_probability): Fix roundoff error.
2003-02-12 Kazu Hirata <kazu@cs.umass.edu> 2003-02-12 Kazu Hirata <kazu@cs.umass.edu>
* config/h8300/h8300.md (a peephole2): Don't handle 65535. * config/h8300/h8300.md (a peephole2): Don't handle 65535.
......
...@@ -449,14 +449,19 @@ estimate_probability (loops_info) ...@@ -449,14 +449,19 @@ estimate_probability (loops_info)
if (simple_loop_p (loops_info, loop, &desc) if (simple_loop_p (loops_info, loop, &desc)
&& desc.const_iter) && desc.const_iter)
{ {
int prob;
niter = desc.niter + 1; niter = desc.niter + 1;
if (niter == 0) /* We might overflow here. */ if (niter == 0) /* We might overflow here. */
niter = desc.niter; niter = desc.niter;
prob = (REG_BR_PROB_BASE
- (REG_BR_PROB_BASE + niter /2) / niter);
/* Branch prediction algorithm gives 0 frequency for everything
after the end of loop for loop having 0 probability to finish. */
if (prob == REG_BR_PROB_BASE)
prob = REG_BR_PROB_BASE - 1;
predict_edge (desc.in_edge, PRED_LOOP_ITERATIONS, predict_edge (desc.in_edge, PRED_LOOP_ITERATIONS,
REG_BR_PROB_BASE prob);
- (REG_BR_PROB_BASE + niter /2)
/ niter);
} }
bbs = get_loop_body (loop); bbs = get_loop_body (loop);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment