+2014-06-03 Dehao Chen <dehao@google.com>
+
+ * tree-cfg.c (gimple_merge_blocks): Only reset count when BBs are in
+ the same loop.
+
2014-06-03 Marek Polacek <polacek@redhat.com>
PR c/60439
+2014-06-03 Dehao Chen <dehao@google.com>
+
+ * gcc.dg/tree-prof/merge_block.c: New test.
+
2014-06-03 Uros Bizjak <ubizjak@gmail.com>
* g++.dg/ext/mv14.C (dg-options): Add -march=x86-64.
--- /dev/null
+
+/* { dg-options "-O2 -fno-ipa-pure-const -fdump-tree-optimized-blocks-details -fno-early-inlining" } */
+int a[8];
+int t()
+{
+ int i;
+ for (i = 0; i < 3; i++)
+ if (a[i])
+ break;
+ return i;
+}
+main ()
+{
+ int i;
+ /* The loop will be optimized away after ipa-inline. */
+ for (i = 0; i < 1000; i++)
+ t ();
+ return 0;
+}
+/* { dg-final-use { scan-tree-dump-not "Invalid sum" "optimized"} } */
+/* { dg-final-use { cleanup-tree-dump "optimized" } } */
/* When merging two BBs, if their counts are different, the larger count
is selected as the new bb count. This is to handle inconsistent
profiles. */
- a->count = MAX (a->count, b->count);
- a->frequency = MAX (a->frequency, b->frequency);
+ if (a->loop_father == b->loop_father)
+ {
+ a->count = MAX (a->count, b->count);
+ a->frequency = MAX (a->frequency, b->frequency);
+ }
/* Merge the sequences. */
last = gsi_last_bb (a);