PR target/41279
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 30 Sep 2009 09:57:56 +0000 (09:57 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 30 Sep 2009 09:57:56 +0000 (09:57 +0000)
* cfgloopanal.c (num_loop_insns): Don't increment ninsns for each bb
before insn counting loop now that BB_END (bb) is counted.  Ensure
the return value isn't zero.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@152324 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/cfgloopanal.c

index 0c6ebdc..3765cba 100644 (file)
@@ -1,3 +1,10 @@
+2009-09-30  Jakub Jelinek  <jakub@redhat.com>
+
+       PR target/41279
+       * cfgloopanal.c (num_loop_insns): Don't increment ninsns for each bb
+       before insn counting loop now that BB_END (bb) is counted.  Ensure
+       the return value isn't zero.
+
 2009-09-30  Nick Clifton  <nickc@redhat.com>
 
        * config.gcc (sh-symbianelf): Replace definition of extra_objs
index 33aff6d..129ec25 100644 (file)
@@ -175,12 +175,14 @@ num_loop_insns (const struct loop *loop)
   for (i = 0; i < loop->num_nodes; i++)
     {
       bb = bbs[i];
-      ninsns++;
       FOR_BB_INSNS (bb, insn)
        if (NONDEBUG_INSN_P (insn))
          ninsns++;
     }
-  free(bbs);
+  free (bbs);
+
+  if (!ninsns)
+    ninsns = 1;        /* To avoid division by zero.  */
 
   return ninsns;
 }
@@ -209,7 +211,7 @@ average_num_loop_insns (const struct loop *loop)
              : (bb->frequency * BB_FREQ_MAX) / loop->header->frequency;
       ninsns += binsns * ratio;
     }
-  free(bbs);
+  free (bbs);
 
   ninsns /= BB_FREQ_MAX;
   if (!ninsns)