public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jan Hubicka <hubicka@ucw.cz>
To: Richard Biener <richard.guenther@gmail.com>, gcc-patches@gcc.gnu.org
Subject: Re: Fix optimize_mask_stores profile update
Date: Mon, 17 Jul 2023 14:38:46 +0200	[thread overview]
Message-ID: <ZLU2Vor5zOz3PIb4@kam.mff.cuni.cz> (raw)
In-Reply-To: <CAFiYyc3xOOcuwG8F8jjywN6zp7FY-q5T-0FW=XhWfyjsxNVJCg@mail.gmail.com>

> 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).

OK, let me see if I can get a testcase out of that.
> >        efalse = make_edge (bb, store_bb, EDGE_FALSE_VALUE);
> >        /* Put STORE_BB to likely part.  */
> >        efalse->probability = profile_probability::unlikely ();
> > +      e->probability = efalse->probability.invert ();
> >        store_bb->count = efalse->count ();
> 
> isn't the count also wrong?  Or rather efalse should be likely().   We're
> testing doing
> 
>   if (!mask all zeros)
>     masked-store
> 
> because a masked store with all zero mask can end up invoking COW page fault
> handling multiple times (because it doesn't actually write).

Hmm, I only fixed the profile, efalse was already set to unlikely, but
indeed I think it should be likely. Maybe we can compute some bound on
actual probability by knowing if(cond[i]) probability.
If the loop always does factor many ones or zeros, the probability would
remain the same.
If that is p and they are all independent, the outcome would be
(1-p)^factor

sp we know the conditoinal shoul dbe in ragne (1-p)^factor....(1-p),
right?

Honza

> 
> Note -Ofast allows store data races and thus does RMW instead of a masked store.
> 
> >        make_single_succ_edge (store_bb, join_bb, EDGE_FALLTHRU);
> >        if (dom_info_available_p (CDI_DOMINATORS))

  reply	other threads:[~2023-07-17 12:38 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 [this message]
2023-07-17 13:26     ` Richard Biener
2023-07-21 17:34   ` Jan Hubicka
2023-07-24  7:28     ` Richard Biener

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=ZLU2Vor5zOz3PIb4@kam.mff.cuni.cz \
    --to=hubicka@ucw.cz \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=richard.guenther@gmail.com \
    /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).