On Fri, Jul 21, 2023 at 7:34 PM Jan Hubicka <hubi...@ucw.cz> wrote:
>
> > On Mon, Jul 17, 2023 at 12:36 PM Jan Hubicka via Gcc-patches
> > <gcc-patches@gcc.gnu.org> wrote:
> > >
> > > Hi,
> > > While looking into sphinx3 regression I noticed that vectorizer produces
> > > BBs with overall probability count 120%.  This patch fixes it.
> > > Richi, I don't know how to create a testcase, but having one would
> > > be nice.
> > >
> > > Bootstrapped/regtested x86_64-linux, commited last night (sorry for
> > > late email)
> >
> > This should trigger with sth like
> >
> >   for (i)
> >     if (cond[i])
> >       out[i] = 1.;
> >
> > so a masked store and then using AVX2+.  ISTR we disable AVX masked
> > stores on zen (but not AVX512).
>
> Richard,
> if we know probability of if (cond[i]) to be p,
> then we know that the combined conditional is somewhere between
>   low = p      (the strategy packing true and falses into VF sized
>                 blocks)
> and
>   high = min (p*vf,1)
>                (the stragegy doing only one true per block if possible)
> Likely value is
>
>   likely = 1-pow(1-p, vf)
>
> I wonder if we can work out p at least in common cases.
> Making store unlikely as we do right now will place it offline with
> extra jump.  Making it likely is better unless p is very small.
>
> I think if p is close to 0 or 1 which may be common case the analysis
> above may be useful. If range [low...high] is small, we can use likely
> and keep it as reliable.
> If it is high, we can probably just end up with guessed value close but
> above 50% so the store stays inline.

I'd say we want to keep the store inline in all cases (we likely lost
any explicit profile info during if-conversion), not sure what we gain
with providing a better "guess" here.  So I think we should simply
go with 'likely' derived from statistical independent events.

If in future we can tie if-conversion and vectorization even closer
we might be able to preserve profile data here.

Richard.

>
> Honza

Reply via email to