public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <richard.guenther@gmail.com>
To: Jan Hubicka <hubicka@ucw.cz>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: Fix optimize_mask_stores profile update
Date: Mon, 24 Jul 2023 09:28:15 +0200	[thread overview]
Message-ID: <CAFiYyc3pDcqPkNy2LafM9mAqgcmn5OrE_Zhx2N0KD2VdwR5KXA@mail.gmail.com> (raw)
In-Reply-To: <ZLrBlCO9ShQAbhxP@kam.mff.cuni.cz>

On Fri, Jul 21, 2023 at 7:34 PM Jan Hubicka <hubicka@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	other threads:[~2023-07-24  7:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-17 10:35 Jan Hubicka
2023-07-17 10:49 ` Richard Biener
2023-07-17 12:38   ` Jan Hubicka
2023-07-17 13:26     ` Richard Biener
2023-07-21 17:34   ` Jan Hubicka
2023-07-24  7:28     ` Richard Biener [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAFiYyc3pDcqPkNy2LafM9mAqgcmn5OrE_Zhx2N0KD2VdwR5KXA@mail.gmail.com \
    --to=richard.guenther@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hubicka@ucw.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).