[Google] Fix the bug in calculating sum_all

Submitted by Dehao Chen on April 11, 2013, 8:56 p.m.

Details

Message ID CAO2gOZVU2objdR7eoL=PY-NotBhCmZePo-fthsNwB95PBSMSBg@mail.gmail.com
State New
Headers show

Commit Message

Dehao Chen April 11, 2013, 8:56 p.m.
Hi,

This patch fix the bug of sum_all, which is used in loop unroll. The
fix will suppress unrolling loops when the program is hot instruction
footprint is large.

Bootstrapped and passed regression tests.

Is it okay for googe-4_7 branch?

Thanks,
Dehao

Comments

Xinliang David Li April 11, 2013, 9:18 p.m.
ok.

David

On Thu, Apr 11, 2013 at 1:56 PM, Dehao Chen <dehao@google.com> wrote:
> Hi,
>
> This patch fix the bug of sum_all, which is used in loop unroll. The
> fix will suppress unrolling loops when the program is hot instruction
> footprint is large.
>
> Bootstrapped and passed regression tests.
>
> Is it okay for googe-4_7 branch?
>
> Thanks,
> Dehao
>
> --- a/gcc/auto-profile.c
> +++ b/gcc/auto-profile.c
> @@ -1172,8 +1172,7 @@ process_auto_profile (void)
>         {
>           (*func_slot)->entry_count += gcov_functions[i].entry_count;
>           (*func_slot)->total_count += gcov_functions[i].total_count;
> -         if ((*func_slot)->total_count > afdo_profile_info->sum_all)
> -           afdo_profile_info->sum_all = (*func_slot)->total_count;
> +         afdo_profile_info->sum_all += (*func_slot)->total_count;
>         }
>        else
>         *func_slot = gcov_functions + i;
> @@ -1275,6 +1274,7 @@ init_auto_profile (void)
>      xcalloc (1, sizeof (struct gcov_ctr_summary));
>    afdo_profile_info->runs = 1;
>    afdo_profile_info->sum_max = 0;
> +  afdo_profile_info->sum_all = 0;
>
>    /* Read the profile from the profile file.  */
>    read_profile ();

Patch hide | download patch | download mbox

--- a/gcc/auto-profile.c
+++ b/gcc/auto-profile.c
@@ -1172,8 +1172,7 @@  process_auto_profile (void)
        {
          (*func_slot)->entry_count += gcov_functions[i].entry_count;
          (*func_slot)->total_count += gcov_functions[i].total_count;
-         if ((*func_slot)->total_count > afdo_profile_info->sum_all)
-           afdo_profile_info->sum_all = (*func_slot)->total_count;
+         afdo_profile_info->sum_all += (*func_slot)->total_count;
        }
       else
        *func_slot = gcov_functions + i;
@@ -1275,6 +1274,7 @@  init_auto_profile (void)
     xcalloc (1, sizeof (struct gcov_ctr_summary));
   afdo_profile_info->runs = 1;
   afdo_profile_info->sum_max = 0;
+  afdo_profile_info->sum_all = 0;

   /* Read the profile from the profile file.  */
   read_profile ();