diff mbox

Update bb count and freq when merging two blocks

Message ID CAO2gOZWsxUcxy4Azjyhbr9qmv4nUzr5zw7hmKqwWK2_Yz4k6JQ@mail.gmail.com
State New
Headers show

Commit Message

Dehao Chen May 16, 2014, 9:25 p.m. UTC
This patch makes sure max count is used when merging two basic blocks.

Bootstrapped and testing on-going.

OK for trunk if test is ok?

Thanks,
Dehao

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

        * tree-cfg.c (gimple_merge_blocks): Updates bb count with max count.

Comments

Jan Hubicka May 16, 2014, 9:28 p.m. UTC | #1
> This patch makes sure max count is used when merging two basic blocks.
> 
> Bootstrapped and testing on-going.
> 
> OK for trunk if test is ok?
> 
> Thanks,
> Dehao
> 
> gcc/ChangeLog:
> 2014-05-16  Dehao Chen  <dehao@google.com>
> 
>         * tree-cfg.c (gimple_merge_blocks): Updates bb count with max count.
> 
> Index: gcc/tree-cfg.c
> ===================================================================
> --- gcc/tree-cfg.c (revision 210531)
> +++ gcc/tree-cfg.c (working copy)
> @@ -1877,6 +1877,15 @@ 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.  */
> +  if (a->count != b->count)
> +    {
> +      a->count = MAX (a->count, b->count);
> +      a->frequency = MAX (a->frequency, b->frequency);
> +    }

I would do max of frequency indpendently on count.  I.e. just remove the conditional around
the MAX operation.
This seems to make sense even w/o profile feedback.

Honza
Jan Hubicka May 16, 2014, 9:28 p.m. UTC | #2
> > This patch makes sure max count is used when merging two basic blocks.
> > 
> > Bootstrapped and testing on-going.
> > 
> > OK for trunk if test is ok?
> > 
> > Thanks,
> > Dehao
> > 
> > gcc/ChangeLog:
> > 2014-05-16  Dehao Chen  <dehao@google.com>
> > 
> >         * tree-cfg.c (gimple_merge_blocks): Updates bb count with max count.
> > 
> > Index: gcc/tree-cfg.c
> > ===================================================================
> > --- gcc/tree-cfg.c (revision 210531)
> > +++ gcc/tree-cfg.c (working copy)
> > @@ -1877,6 +1877,15 @@ 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.  */
> > +  if (a->count != b->count)
> > +    {
> > +      a->count = MAX (a->count, b->count);
> > +      a->frequency = MAX (a->frequency, b->frequency);
> > +    }
> 
> I would do max of frequency indpendently on count.  I.e. just remove the conditional around
> the MAX operation.
> This seems to make sense even w/o profile feedback.

And patch is OK with that change.

Honza
> 
> Honza
diff mbox

Patch

Index: gcc/tree-cfg.c
===================================================================
--- gcc/tree-cfg.c (revision 210531)
+++ gcc/tree-cfg.c (working copy)
@@ -1877,6 +1877,15 @@  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.  */
+  if (a->count != b->count)
+    {
+      a->count = MAX (a->count, b->count);
+      a->frequency = MAX (a->frequency, b->frequency);
+    }
+
   /* Merge the sequences.  */
   last = gsi_last_bb (a);
   gsi_insert_seq_after (&last, bb_seq (b), GSI_NEW_STMT);