public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/102436] [11/12 Regression] Lost Load/Store Motion
Date: Wed, 22 Sep 2021 07:18:54 +0000	[thread overview]
Message-ID: <bug-102436-4-uq080Seewy@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-102436-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102436

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Target Milestone|---                         |11.3
           Priority|P3                          |P2
           Keywords|                            |missed-optimization
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot gnu.org
   Last reconfirmed|                            |2021-09-22
             Status|UNCONFIRMED                 |ASSIGNED

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Memory reference 3: numb_moves
Memory reference 4: _24->from
...
Querying dependency of refs 3 and 4: dependent.
Querying SM WAW dependencies of ref 3 in loop 1: dependent

the issue is that we require conditional executed stores to be independent
on all other stores as we cannot re-issue other stores on exit in the proper
order.

Now, in this case the dependent stores are executed under the same condition
and in fact ordered in a way that we don't have to re-issue any dependent
store.

We're failing to handle this special case after the store-motion re-write that
fixed the TBAA issues.

Smaller testcase where we can just issue the conditional store to 'p':

unsigned p;
void foo (float *q)
{
  for (int i = 0; i < 256; ++i)
    {
      if (p)
        {
          unsigned a = p;
          *(q++) = 1.;
          p = a + 1;
        }
    }
}

the following are what's very much more difficult to handle
(we have to issue a conditional sequence of two stores, and remember the
location the non-invariant store stored to _and_ verify we can re-emit that
out-of-order, and we have to remember the value stored):

unsigned p;
void foo (float *q)
{
  for (int i = 0; i < 256; ++i)
    {
      if (p)
        {
          unsigned a = p;
          p = a + 1;
          *(q++) = 1.;
        }
    }
}

a bit easier (the store we have to re-issue is always executed after the
last conditional store):

unsigned p;
void foo (float *q)
{
  for (int i = 0; i < 256; ++i)
    {
      if (p)
        {
          unsigned a = p;
          p = a + 1;
        }
      *(q++) = 1.;
    }
}

impossible / invalid:

unsigned p;
void foo (float *q)
{
  for (int i = 0; i < 256; ++i)
    {
      *(q++) = 1.;
      if (p)
        {
          unsigned a = p;
          p = a + 1;
        }
    }
}

I will see how difficult it is to teach the already interwinded code the
"trivial" case and whether the bit easier case falls out naturally.

  reply	other threads:[~2021-09-22  7:18 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-21 20:09 [Bug tree-optimization/102436] New: " law at gcc dot gnu.org
2021-09-22  7:18 ` rguenth at gcc dot gnu.org [this message]
2021-11-16 14:57 ` [Bug tree-optimization/102436] " rguenth at gcc dot gnu.org
2021-11-19  8:35 ` cvs-commit at gcc dot gnu.org
2021-11-19  8:37 ` rguenth at gcc dot gnu.org
2021-11-19 15:28 ` [Bug tree-optimization/102436] [11 " law at gcc dot gnu.org
2022-04-21  7:50 ` rguenth at gcc dot gnu.org
2023-05-29 10:05 ` jakub at gcc dot gnu.org

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=bug-102436-4-uq080Seewy@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /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).