tree-cfg.c (gimple_merge_blocks): Only reset count when BBs are in the same loop.

2014-06-03  Dehao Chen  <dehao@google.com>

	* tree-cfg.c (gimple_merge_blocks): Only reset count when BBs are in
	the same loop.
	* gcc.dg/tree-prof/merge_block.c: New test.

From-SVN: r211202
This commit is contained in:
Dehao Chen 2014-06-03 21:36:05 +00:00 committed by Dehao Chen
parent eb7404d46a
commit 47e78f984e
4 changed files with 35 additions and 2 deletions

View File

@ -1,3 +1,8 @@
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

View File

@ -1,3 +1,7 @@
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.

View File

@ -0,0 +1,21 @@
/* { 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" } } */

View File

@ -1880,8 +1880,11 @@ gimple_merge_blocks (basic_block a, basic_block b)
/* 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);