* predict.c (combine_predictions_for_insn): Avoid division by zero.
authorJakub Jelinek <jakub@redhat.com>
Mon, 7 Jan 2002 21:15:12 +0000 (22:15 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 7 Jan 2002 21:15:12 +0000 (22:15 +0100)
From-SVN: r48615

gcc/ChangeLog
gcc/predict.c

index bac2003e3ea51f789d860b856588ae7d9bfb2f9c..6f8967fe617d00fe452adbe6ed496f0449d2e1c8 100644 (file)
@@ -1,3 +1,7 @@
+2002-01-07  Jakub Jelinek  <jakub@redhat.com>
+
+       * predict.c (combine_predictions_for_insn): Avoid division by zero.
+
 2002-01-07  Jakub Jelinek  <jakub@redhat.com>
 
        * simplify-rtx.c (simplify_plus_minus): Bump n_ops for NOT.
index 71da61a7c17cb9b46bb6837bf7ac6689548477a1..c35837ed2b7eb413a462ef2ddb8c9271c31370e3 100644 (file)
@@ -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,