public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Updates merged bb count
@ 2014-05-30 21:43 Dehao Chen
  2014-05-30 23:51 ` Steven Bosscher
  0 siblings, 1 reply; 3+ messages in thread
From: Dehao Chen @ 2014-05-30 21:43 UTC (permalink / raw)
  To: GCC Patches; +Cc: Jan Hubicka

This patch updates the merged bb count only when they are in the same loop.

Bootstrapped and passed regression test.

Ok for trunk?

Thanks,
Dehao

gcc/ChangeLog:
2014-05-30  Dehao Chen  <dehao@google.com>

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

gcc/testsuite/ChangeLog:
2014-05-30  Dehao Chen  <dehao@google.com>

        * gcc.dg/tree-prof/merge_block.c: New test.

Index: gcc/testsuite/gcc.dg/tree-prof/merge_block.c
===================================================================
--- gcc/testsuite/gcc.dg/tree-prof/merge_block.c (revision 0)
+++ gcc/testsuite/gcc.dg/tree-prof/merge_block.c (revision 0)
@@ -0,0 +1,20 @@
+
+/* { 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;
+  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" } } */
Index: gcc/tree-cfg.c
===================================================================
--- gcc/tree-cfg.c (revision 211096)
+++ gcc/tree-cfg.c (working copy)
@@ -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);

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Updates merged bb count
  2014-05-30 21:43 [PATCH] Updates merged bb count Dehao Chen
@ 2014-05-30 23:51 ` Steven Bosscher
  2014-05-31  0:23   ` Dehao Chen
  0 siblings, 1 reply; 3+ messages in thread
From: Steven Bosscher @ 2014-05-30 23:51 UTC (permalink / raw)
  To: Dehao Chen; +Cc: GCC Patches, Jan Hubicka

On Fri, May 30, 2014 at 11:43 PM, Dehao Chen wrote:
> Index: gcc/testsuite/gcc.dg/tree-prof/merge_block.c
> ===================================================================
> --- gcc/testsuite/gcc.dg/tree-prof/merge_block.c (revision 0)
> +++ gcc/testsuite/gcc.dg/tree-prof/merge_block.c (revision 0)
> @@ -0,0 +1,20 @@
> +
> +/* { 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;
> +  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" } } */


I suppose you want to avoid having t() inlined into main()? If so,
then I'd suggest adding __attribute__((__noinline__,__noclone__)) to
"robustify" the test case.

Ciao!
Steven

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Updates merged bb count
  2014-05-30 23:51 ` Steven Bosscher
@ 2014-05-31  0:23   ` Dehao Chen
  0 siblings, 0 replies; 3+ messages in thread
From: Dehao Chen @ 2014-05-31  0:23 UTC (permalink / raw)
  To: Steven Bosscher; +Cc: GCC Patches, Jan Hubicka

Thanks for the suggestion. I actually want this function to be inlined
in ipa-inline phase, not einline phase.

Dehao

On Fri, May 30, 2014 at 4:50 PM, Steven Bosscher <stevenb.gcc@gmail.com> wrote:
> On Fri, May 30, 2014 at 11:43 PM, Dehao Chen wrote:
>> Index: gcc/testsuite/gcc.dg/tree-prof/merge_block.c
>> ===================================================================
>> --- gcc/testsuite/gcc.dg/tree-prof/merge_block.c (revision 0)
>> +++ gcc/testsuite/gcc.dg/tree-prof/merge_block.c (revision 0)
>> @@ -0,0 +1,20 @@
>> +
>> +/* { 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;
>> +  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" } } */
>
>
> I suppose you want to avoid having t() inlined into main()? If so,
> then I'd suggest adding __attribute__((__noinline__,__noclone__)) to
> "robustify" the test case.
>
> Ciao!
> Steven

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-05-31  0:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-30 21:43 [PATCH] Updates merged bb count Dehao Chen
2014-05-30 23:51 ` Steven Bosscher
2014-05-31  0:23   ` Dehao Chen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).