[PATCH] [pr#83069] Keep profile_count for bb under real_bb_freq_max

Siddhesh Poyarekar siddhesh@gotplt.org
Tue Nov 28 11:49:00 GMT 2017


On Friday 24 November 2017 05:36 PM, Siddhesh Poyarekar wrote:
> freq_max < 1, i.e. highest frequency among bbs in the function being
> higher than real_bb_freq_max means that the bb ends up with a profile
> count larger than real_bb_freq_max and then can go all the way up to
> and beyond profile_count::max_count.
> 
> Bootstrapped on aarch64, testsuite in progress.

Tests came out clean (no new regressions) on aarch64 and x86_64.  Ping?

Siddhesh

> 
> 	* gcc/predict.c (estimate_bb_frequencies): Don't reset freq_max.
> 	* gcc/testsuite/gcc.dg/pr83069.c: New test case.
> 
> ---
>  gcc/predict.c                  |  2 --
>  gcc/testsuite/gcc.dg/pr83069.c | 15 +++++++++++++++
>  2 files changed, 15 insertions(+), 2 deletions(-)
>  create mode 100644 gcc/testsuite/gcc.dg/pr83069.c
> 
> diff --git a/gcc/predict.c b/gcc/predict.c
> index 0f34956..ff9b5a9 100644
> --- a/gcc/predict.c
> +++ b/gcc/predict.c
> @@ -3613,8 +3613,6 @@ estimate_bb_frequencies (bool force)
>  	  freq_max = BLOCK_INFO (bb)->frequency;
>  
>        freq_max = real_bb_freq_max / freq_max;
> -      if (freq_max < 16)
> -	freq_max = 16;
>        profile_count ipa_count = ENTRY_BLOCK_PTR_FOR_FN (cfun)->count.ipa ();
>        cfun->cfg->count_max = profile_count::uninitialized ();
>        FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR_FOR_FN (cfun), NULL, next_bb)
> diff --git a/gcc/testsuite/gcc.dg/pr83069.c b/gcc/testsuite/gcc.dg/pr83069.c
> new file mode 100644
> index 0000000..d43d78d
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/pr83069.c
> @@ -0,0 +1,15 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O1" } */
> +
> +void
> +foo (unsigned long *res, unsigned long in)
> +{
> +  for (unsigned long a = 0; a < 98; a++)
> +    for (unsigned long b = 0; b < 98; b++)
> +      for (unsigned long c = 0; c < 98; c++)
> +	for (unsigned long d = 0; d < 98; d++)
> +	  for (unsigned long e = 0; e < 98; e++)
> +	    for (unsigned long f = 0; f < 98; f++)
> +	      for (unsigned long g = 0; g < 98; g++)
> +		*res += a * in;
> +}
> 



More information about the Gcc-patches mailing list