This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [GOOGLE] Fix a bug when profile propagation handles infinite loop.
- From: Xinliang David Li <davidxl at google dot com>
- To: Dehao Chen <dehao at google dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 25 Oct 2013 18:49:38 -0700
- Subject: Re: [GOOGLE] Fix a bug when profile propagation handles infinite loop.
- Authentication-results: sourceware.org; auth=none
- References: <CAO2gOZXhTsakGMtx+KQ0F550A7KYgXtUr93FXK8V-TMhsQi-yg at mail dot gmail dot com> <CAAkRFZLJu00sGJH-9OSQ-fWGFfoaNh=o3Sv4oo0w6PO9zRe5oQ at mail dot gmail dot com> <CAO2gOZWN9bt8r4NojLN+YK0m4z00qpt0JOxCFNFrqQkW+0jz1Q at mail dot gmail dot com>
Ok with the change.
David
On Fri, Oct 25, 2013 at 6:17 PM, Dehao Chen <dehao@google.com> wrote:
> Most are within 10. The largest one I see is 17 across all benchmark.
>
> Dehao
>
> On Fri, Oct 25, 2013 at 4:21 PM, Xinliang David Li <davidxl@google.com> wrote:
>> What is the usual number of iterations?
>>
>> David
>>
>> On Fri, Oct 25, 2013 at 4:10 PM, Dehao Chen <dehao@google.com> wrote:
>>> If the propagation finds an infinite look, if the in-edge count is
>>> non-zero, then it will cause compiler go into infinite loop when
>>> building with AutoFDO.
>>>
>>> Bootstrapped and regression test on-going.
>>>
>>> OK for google-4_8 branch?
>>>
>>> Thanks,
>>> Dehao
>>>
>>> Index: gcc/auto-profile.c
>>> ===================================================================
>>> --- gcc/auto-profile.c (revision 204027)
>>> +++ gcc/auto-profile.c (working copy)
>>> @@ -1287,6 +1287,7 @@ afdo_propagate (void)
>>> {
>>> basic_block bb;
>>> bool changed = true;
>>> + int i = 0;
>>>
>>> FOR_ALL_BB (bb)
>>> {
>>> @@ -1295,7 +1296,7 @@ afdo_propagate (void)
>>> bb->flags |= BB_ANNOTATED;
>>> }
>>>
>>> - while (changed)
>>> + while (changed && i++ < PARAM_VALUE (PARAM_AUTOFDO_MAX_PROPAGATE_ITERATIONS))
>>> {
>>> changed = false;
>>>
>>> Index: gcc/params.def
>>> ===================================================================
>>> --- gcc/params.def (revision 204027)
>>> +++ gcc/params.def (working copy)
>>> @@ -460,6 +460,14 @@ DEFPARAM(PARAM_MAX_PREDICTED_ITERATIONS,
>>> "The maximum number of loop iterations we predict statically",
>>> 100, 0, 0)
>>>
>>> +/* This parameter controls the maximum iterations that AutoFDO profile
>>> + prpagation algorithm will run for a specific CFG. */
>>> +
>>> +DEFPARAM(PARAM_AUTOFDO_MAX_PROPAGATE_ITERATIONS,
>>> + "max-autofdo-max-propagate-iterations",
>>> + "The maximum number of AutoFDO profile propagation iterations",
>>> + 1000, 0, 0)
>>> +
>>> /* This parameter controls the probability of builtin_expect. The default
>>> value is 90%. This empirical value is obtained through the weighted
>>> probability of FDO counters (with the FDO count value as the weight)