Re: [AutoFDO] prevent head_count of 0 with AFDO profile.

Jan Hubička <[email protected]>
Newsgroups gmane.comp.gcc.patches
Message-ID <CAJf+ejfXhUWK3+EWSYg6ti2wdCDQQE9oUwoUywyY35ssZs=5CQ@mail.gmail.com>
Hell,
this is OK,
thanks
Honza

On Thu, Aug 20, 2026 at 1:01 AM Kugan Vivekanandarajah <
[email protected]> wrote:

> Hi Honza,
>
> Thanks for the review.
>
> > On 4 Aug 2026, at 5:07 pm, Jan Hubička <[email protected]> wrote:
> >
> > External email: Use caution opening links or attachments
> > Kugan,
> > I apologize for late reaction. I finally got to reproduce this.
> > I think we want to set the entry block count to
> >  MAX (1, afdo_count_scale / 2)
> > Receiving 0 samples on code that is known to be executed means that the
> real value should be somewhere between 0 and 1, so 1/2 is good estimate.
> Setting count 1 will make all basic blocks to appear very hot and confuse
> the logic computing BB frequency.
> >
> > Also I think you can do that just once in  afdo_calculate_branch_prob
> > just after calling afdo_adjust_guessed_profile instead of doing it as a
> > part of the fixup algorithm (which is already bit complicated).
>
> Yes, this helps. I have added in one place as you suggested and this fixes
> the ICE.
> If you don't have any objections, I will commit this patch.
>
> Thanks,
> Kugan
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.