diff options
author | Jakub Jelinek <jakub@redhat.com> | 2002-01-07 22:15:12 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2002-01-07 22:15:12 +0100 |
commit | 571a03b876a6b4b7db3fb2051f0b50f58ecd3a91 (patch) | |
tree | 3d8f82c5ac3ab5424c7e563aa3d650605ea6f0e7 /gcc/predict.c | |
parent | 2e9513841e7b1614d5bcde97e7af166481728296 (diff) | |
download | gcc-571a03b876a6b4b7db3fb2051f0b50f58ecd3a91.zip gcc-571a03b876a6b4b7db3fb2051f0b50f58ecd3a91.tar.gz gcc-571a03b876a6b4b7db3fb2051f0b50f58ecd3a91.tar.bz2 |
* predict.c (combine_predictions_for_insn): Avoid division by zero.
From-SVN: r48615
Diffstat (limited to 'gcc/predict.c')
-rw-r--r-- | gcc/predict.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/gcc/predict.c b/gcc/predict.c index 71da61a..c35837e 100644 --- a/gcc/predict.c +++ b/gcc/predict.c @@ -253,8 +253,12 @@ combine_predictions_for_insn (insn, bb) * (REG_BR_PROB_BASE - probability)); /* Use FP math to avoid overflows of 32bit integers. */ - combined_probability = (((double) combined_probability) * probability - * REG_BR_PROB_BASE / d + 0.5); + if (d == 0) + /* If one probability is 0% and one 100%, avoid division by zero. */ + combined_probability = REG_BR_PROB_BASE / 2; + else + combined_probability = (((double) combined_probability) * probability + * REG_BR_PROB_BASE / d + 0.5); } /* Decide which heuristic to use. In case we didn't match anything, |