diff mbox

[GOOGLE] Adjust profile for AutoFDO

Message ID CAO2gOZW+Fz=usm=MkqV6fsUhxj4va9VHYP1R0zPqTVAhUN3a3g@mail.gmail.com
State New
Headers show

Commit Message

Dehao Chen Jan. 25, 2014, 5:28 a.m. UTC
This patch fixes performance regression for AutoFDO. When the entry
block count is 0, which is quite possible in AutoFDO, it can still
make right optimization decision.

Bootstrapped passed regression test and performance test (improve 0.5%
on average).

OK for google-4_8?

Thanks,
Dehao

Comments

Xinliang David Li Jan. 27, 2014, 5:26 p.m. UTC | #1
Ok.

For future cleanup, It will be better to define a new helper function
is_profile_missing_p (cfun) -- which checks entry count for
instrumentation based FDO, and something else for autofdo.

David

On Fri, Jan 24, 2014 at 9:28 PM, Dehao Chen <dehao@google.com> wrote:
> This patch fixes performance regression for AutoFDO. When the entry
> block count is 0, which is quite possible in AutoFDO, it can still
> make right optimization decision.
>
> Bootstrapped passed regression test and performance test (improve 0.5%
> on average).
>
> OK for google-4_8?
>
> Thanks,
> Dehao
diff mbox

Patch

Index: gcc/bb-reorder.c
===================================================================
--- gcc/bb-reorder.c	(revision 207066)
+++ gcc/bb-reorder.c	(working copy)
@@ -1564,15 +1564,14 @@  find_rarely_executed_basic_blocks_and_crossing_edg
   /* Mark which partition (hot/cold) each basic block belongs in.  */
   FOR_EACH_BB (bb)
     {
-      bool cold_bb = false;
+      bool cold_bb = probably_never_executed_bb_p (cfun, bb);
 
-      if (probably_never_executed_bb_p (cfun, bb))
+      if (!flag_auto_profile && cold_bb)
         {
           /* Handle profile insanities created by upstream optimizations
              by also checking the incoming edge weights. If there is a non-cold
              incoming edge, conservatively prevent this block from being split
              into the cold section.  */
-          cold_bb = true;
           FOR_EACH_EDGE (e, ei, bb->preds)
             if (!probably_never_executed_edge_p (cfun, e))
               {
Index: gcc/predict.c
===================================================================
--- gcc/predict.c	(revision 207066)
+++ gcc/predict.c	(working copy)
@@ -2902,7 +2902,7 @@  counts_to_freqs (void)
   /* Don't overwrite the estimated frequencies when the profile for
      the function is missing.  We may drop this function PROFILE_GUESSED
      later in drop_profile ().  */
-  if (!ENTRY_BLOCK_PTR->count)
+  if (!flag_auto_profile && !ENTRY_BLOCK_PTR->count)
     return 0;
 
   FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, NULL, next_bb)
@@ -3161,7 +3161,8 @@  rebuild_frequencies (void)
     count_max = MAX (bb->count, count_max);
 
   if (profile_status == PROFILE_GUESSED
-      || (profile_status == PROFILE_READ && count_max < REG_BR_PROB_BASE/10))
+      || (!flag_auto_profile && profile_status == PROFILE_READ
+	  && count_max < REG_BR_PROB_BASE/10))
     {
       loop_optimizer_init (0);
       add_noreturn_fake_exit_edges ();