This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH AutoFDO/2]Treat ZERO as common profile probability/count
- From: "Bin.Cheng" <amker dot cheng at gmail dot com>
- To: Richard Guenther <richard dot guenther at gmail dot com>
- Cc: bin dot cheng at linux dot alibaba dot com, Jan Hubicka <hubicka at ucw dot cz>, gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 31 Oct 2018 17:35:21 +0800
- Subject: Re: [PATCH AutoFDO/2]Treat ZERO as common profile probability/count
- References: <7f153787-f390-4661-92aa-06d47cefbbf5.bin.cheng@linux.alibaba.com> <CAFiYyc0Dj7y4fe8Jj9JGZp3xh0h=vEbohs7kccO5RsXe5u4GNg@mail.gmail.com>
On Wed, Oct 31, 2018 at 5:11 PM Richard Biener
<richard.guenther@gmail.com> wrote:
>
> On Wed, Oct 31, 2018 at 7:30 AM bin.cheng <bin.cheng@linux.alibaba.com> wrote:
> >
> > Hi,
> > In new profile probability/count infra, we have different precision quality categories,
> > and probabilities/counts of different categories are not supposed to be compared or
> > calculated. Though in general is an improvement, it introduces unexpected behavior.
> > Specifically, class profile_probablity and profile_count themselves are implemented
> > by comparing probabilities/counts against profile_count::zero(). while zero() is of
> > profile_precision category, it's always compared different to zero of other precision
> > categories including afdo.
> >
> > I can see two ways fixing this: 1) Treat zero as a common probability/count regardless
> > of its category; 2) Provide an "is_zero" method rather than relying on "==" comparison
> > against probability_count::zero(). 2) requires lots of code changes so I went with 1)
> > in this patch set. This patch doesn't handle "always" but it might be.
> >
> > This patch also corrects a minor issue where we try to invert an uninitialized value.
> >
> > Bootstrap and test on x86_64 in patch set. Is it OK?
>
> I'll defer on the emit_store_flag_force change, likewise for the zero
> handling in
> compares - I don't think zeros of different qualities should compare equal.
> Would compares against ::always() not have the very same issue?
> Likewise ::even(),
> ::likely(), etc.? Those always get guessed quality.
Yes, these values also affected if compared with precise category, but
zero is the major issue. So 2) makes more sense when checking if a
profile count is_zero/is_likely/is_always etc. regardless of its categories.
Once with Honza's input, I can do some experiments.
Thanks,
bin
>
> The invert change looks OK to me. The related change to the always() API would
> suggest to replace guessed_always() with always (guessed) and also do similar
> changes throughout the whole API...
>
> Honza?
>
> Thanks,
> Richard.
>
>
> > Thanks,
> > bin
> >
> > 2018-10-31 Bin Cheng <bin.cheng@linux.alibaba.com>
> >
> > * expmed.c (emit_store_flag_force): Use profile_probability::always.
> > * profile-count.h (profile_probability::always): Add parameter.
> > (profile_probability::operator==, profile_count::operator==): Treat
> > ZERO as common probability/count regardless of its quality.
> > (profile_probability::invert): Don't invert uninitialized probability.