tree-ssa-tail-merge.c (replace_block_by): Update edge weights during merging.
authorTeresa Johnson <tejohnson@google.com>
Fri, 18 Oct 2013 14:36:53 +0000 (14:36 +0000)
committerTeresa Johnson <tejohnson@gcc.gnu.org>
Fri, 18 Oct 2013 14:36:53 +0000 (14:36 +0000)
2013-10-18  Teresa Johnson  <tejohnson@google.com>

* tree-ssa-tail-merge.c (replace_block_by): Update edge
weights during merging.

From-SVN: r203823

gcc/ChangeLog
gcc/tree-ssa-tail-merge.c

index 71298916e3b167b333fa8ff13df40fd9b0c8a1d3..a677fa4b77ca158f4ee77e124feec8615fa07fb7 100644 (file)
@@ -1,3 +1,8 @@
+2013-10-18  Teresa Johnson  <tejohnson@google.com>
+
+       * tree-ssa-tail-merge.c (replace_block_by): Update edge
+       weights during merging.
+
 2013-10-18  Andrew MacLeod  <amacleod@redhat.com>
 
        * tree-cfg.h: Rename from tree-flow.h.  Remove #includes.
index 4998b7e616cee046d502f36212de957f942c6de7..9094935391c8e9de64db4d4858bd0c27af709f0d 100644 (file)
@@ -1462,6 +1462,8 @@ static void
 replace_block_by (basic_block bb1, basic_block bb2)
 {
   edge pred_edge;
+  edge e1;
+  edge_iterator ei;
   unsigned int i;
   gimple bb2_phi;
 
@@ -1494,6 +1496,18 @@ replace_block_by (basic_block bb1, basic_block bb2)
 
   bb2->count += bb1->count;
 
+  /* Merge the outgoing edge counts from bb1 onto bb2.  */
+  FOR_EACH_EDGE (e1, ei, bb1->succs)
+    {
+      edge e2;
+      e2 = find_edge (bb2, e1->dest);
+      gcc_assert (e2);
+      e2->count += e1->count;
+      /* Recompute the probability from the new merged edge count (bb2->count
+         was updated above).  */
+      e2->probability = GCOV_COMPUTE_SCALE (e2->count, bb2->count);
+    }
+
   /* Do updates that use bb1, before deleting bb1.  */
   release_last_vdef (bb1);
   same_succ_flush_bb (bb1);