ipa-icf.c (sem_item_optimizer::parse_nonsingleton_classes): Guard division by zero...
authorMartin Liska <mliska@suse.cz>
Fri, 24 Oct 2014 06:06:20 +0000 (08:06 +0200)
committerUros Bizjak <uros@gcc.gnu.org>
Fri, 24 Oct 2014 06:06:20 +0000 (08:06 +0200)
* ipa-icf.c (sem_item_optimizer::parse_nonsingleton_classes): Guard
division by zero in dumps.
(sem_item_optimizer::merge_classes): Ditto.

From-SVN: r216612

gcc/ChangeLog
gcc/ipa-icf.c

index 4187dd9651fc903bec673abf109841d00ea46ec6..cefe8ffab74970a7f1a92cd9bd1a5a7c7e955687 100644 (file)
@@ -1,3 +1,9 @@
+2014-10-24  Martin Liska  <mliska@suse.cz>
+
+       * ipa-icf.c (sem_item_optimizer::parse_nonsingleton_classes): Guard
+       division by zero in dumps.
+       (sem_item_optimizer::merge_classes): Ditto.
+
 2014-10-23  John David Anglin  <danglin@gcc.gnu.org>
 
        * config/pa/pa.c (pa_can_combine_p): Fix typo in last change.
index d1238a4ce8b5a31417d1fbb5bd546d4845c986bc..e8c32c704d9e50986d8d26a496db8bdca97f02e9 100644 (file)
@@ -1736,7 +1736,7 @@ sem_item_optimizer::parse_nonsingleton_classes (void)
 
   if (dump_file)
     fprintf (dump_file, "Init called for %u items (%.2f%%).\n", init_called_count,
-            100.0f * init_called_count / m_items.length ());
+            m_items.length () ? 100.0f * init_called_count / m_items.length (): 0.0f);
 }
 
 /* Equality function for semantic items is used to subdivide existing
@@ -2196,14 +2196,15 @@ sem_item_optimizer::merge_classes (unsigned int prev_class_count)
       fprintf (dump_file, "Congruent classes before: %u, after: %u\n",
               prev_class_count, class_count);
       fprintf (dump_file, "Average class size before: %.2f, after: %.2f\n",
-              1.0f * item_count / prev_class_count,
-              1.0f * item_count / class_count);
+              prev_class_count ? 1.0f * item_count / prev_class_count : 0.0f,
+              class_count ? 1.0f * item_count / class_count : 0.0f);
       fprintf (dump_file, "Average non-singular class size: %.2f, count: %u\n",
-              1.0f * non_singular_classes_sum / non_singular_classes_count,
+              non_singular_classes_count ? 1.0f * non_singular_classes_sum /
+              non_singular_classes_count : 0.0f,
               non_singular_classes_count);
       fprintf (dump_file, "Equal symbols: %u\n", equal_items);
       fprintf (dump_file, "Fraction of visited symbols: %.2f%%\n\n",
-              100.0f * equal_items / item_count);
+              item_count ? 100.0f * equal_items / item_count : 0.0f);
     }
 
   for (hash_table<congruence_class_group_hash>::iterator it = m_classes.begin ();