Handle loops with loop->latch == NULL (PR gcov-profile/71868)
authorMartin Liska <mliska@suse.cz>
Mon, 25 Jul 2016 10:56:08 +0000 (12:56 +0200)
committerMartin Liska <marxin@gcc.gnu.org>
Mon, 25 Jul 2016 10:56:08 +0000 (10:56 +0000)
PR gcov-profile/71868
* cfgloopanal.c (expected_loop_iterations_unbounded): When we
have a function with multiple latches, count them all.

From-SVN: r238706

gcc/ChangeLog
gcc/cfgloopanal.c

index 18a969f46e6f164636340f8d7d4b83d212bb6954..7a8a69c5a453d9f1e18cebf9f1b70f0fa7be7d48 100644 (file)
@@ -1,3 +1,9 @@
+2016-07-25  Martin Liska  <mliska@suse.cz>
+
+       PR gcov-profile/71868
+       * cfgloopanal.c (expected_loop_iterations_unbounded): When we
+       have a function with multiple latches, count them all.
+
 2016-07-25  Martin Liska  <mliska@suse.cz>
 
        * tree-ssa-loop-niter.c (loop_only_exit_p): Release body array.
index 2739f44a3a62489faa8b9a0c4e7025253cabed1e..001cf45ee9c975bfd9cc3dd33867756e0fcb6403 100644 (file)
@@ -244,7 +244,7 @@ expected_loop_iterations_unbounded (const struct loop *loop,
   /* If we have no profile at all, use AVG_LOOP_NITER.  */
   if (profile_status_for_fn (cfun) == PROFILE_ABSENT)
     expected = PARAM_VALUE (PARAM_AVG_LOOP_NITER);
-  else if (loop->latch->count || loop->header->count)
+  else if (loop->latch && (loop->latch->count || loop->header->count))
     {
       gcov_type count_in, count_latch;
 
@@ -274,8 +274,8 @@ expected_loop_iterations_unbounded (const struct loop *loop,
       freq_latch = 0;
 
       FOR_EACH_EDGE (e, ei, loop->header->preds)
-       if (e->src == loop->latch)
-         freq_latch = EDGE_FREQUENCY (e);
+       if (flow_bb_inside_loop_p (loop, e->src))
+         freq_latch += EDGE_FREQUENCY (e);
        else
          freq_in += EDGE_FREQUENCY (e);