This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] PR40119
- From: Richard Guenther <richard dot guenther at gmail dot com>
- To: Steven Bosscher <stevenb dot gcc at gmail dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Sat, 13 Feb 2010 00:34:38 +0100
- Subject: Re: [patch] PR40119
- References: <571f6b511002121333l5a036bf3jd82731071a312e9@mail.gmail.com>
On Fri, Feb 12, 2010 at 10:33 PM, Steven Bosscher <stevenb.gcc@gmail.com> wrote:
> Hi,
>
> This fixes PR40119, which concerns a floating-point error
> (divide-by-zero) when "--param hot-bb-frequency-fraction=0" is given.
>
> Solution is simple: Catch this exceptional case early.
>
> Bootstrapped&tested on x86_64-unknown-linux-gnu (C only). OK for trunk?
Hm, why not simply limit the valid range for hot-bb-frequency-fraction
appropriately? Like from 1, 10000? Same issue for hot-bb-count-fraction
I guess. The documentation also needs some TLC (and research
as to what "fraction of the maximal frequency" exactly means.
Richard.
> Ciao!
> Steven
>
>
> gcc/
> ? ? ? ?* predict.c (maybe_hot_frequency_p): If a frequency of 0 is also
> ? ? ? ?to be considered "hot", return true at once.
> ? ? ? ?(cgraph_maybe_hot_edge_p): Likewise.
>
> testsuite/
> ? ? ? ?gcc.dg/pr40119.c: New test.
>
> Index: predict.c
> ===================================================================
> --- predict.c ? (revision 156706)
> +++ predict.c ? (working copy)
> @@ -113,6 +113,8 @@ static const struct predictor_info predi
> ?static inline bool
> ?maybe_hot_frequency_p (int freq)
> ?{
> + ?if (PARAM_VALUE (HOT_BB_FREQUENCY_FRACTION) == 0)
> + ? ?return true;
> ? if (!profile_info || !flag_branch_probabilities)
> ? ? {
> ? ? ? if (cfun->function_frequency == FUNCTION_FREQUENCY_UNLIKELY_EXECUTED)
> @@ -157,6 +159,8 @@ maybe_hot_bb_p (const_basic_block bb)
> ?bool
> ?cgraph_maybe_hot_edge_p (struct cgraph_edge *edge)
> ?{
> + ?if (PARAM_VALUE (HOT_BB_FREQUENCY_FRACTION) == 0)
> + ? ?return true;
> ? if (profile_info && flag_branch_probabilities
> ? ? ? && (edge->count
> ? ? ? ? ?<= profile_info->sum_max / PARAM_VALUE (HOT_BB_COUNT_FRACTION)))
> Index: testsuite/gcc.dg/pr40119.c
> ===================================================================
> --- testsuite/gcc.dg/pr40119.c ?(revision 0)
> +++ testsuite/gcc.dg/pr40119.c ?(revision 0)
> @@ -0,0 +1,5 @@
> +/* PR middle-end/40119 */
> +/* { dg-do compile } */
> +/* { dg-options "-O --param hot-bb-frequency-fraction=0" } */
> +void foo(void) { return; }
> +
>