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/106365] Miss to handle ifn .LEN_STORE in FRE
Date: Wed, 20 Jul 2022 09:01:52 +0000	[thread overview]
Message-ID: <bug-106365-4-PiwhqNDAEl@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-106365-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
int __attribute__((noinline,noclone))
foo (int *out)
{
  int mask[] = { 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1,
      0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1 };
  int i;
  for (i = 0; i < 32; ++i)
    {
      if (mask[i])
        out[i] = i;
    }
  return out[7];
}

testcase for x86_64 and .MASK_STORE, could be optimized to return 1.  FRE
sees

  .MASK_STORE (out_41(D), 32B, mask__7.9_47, { 0, 1, 2, 3, 4, 5, 6, 7 });
  _10 = &mask[8] + 32;
  MEM <vector(8) int> [(int *)_10] = { 0, 1, 0, 1, 0, 1, 0, 1 };

and 'mask' having address taken makes it clobbered by .MASK_STORE.  There's
also the older issue that when mask is incoming but marked __restrict that
isn't good enough because __restrict and calls doesn't work.

The IL with .LEN_STORE might suffer similar issues at the point FRE gets
to see it.

We might be able to improve BB SLP to not code-gen

  _10 = &mask[8] + 32;
  MEM <vector(8) int> [(int *)_10] = { 0, 1, 0, 1, 0, 1, 0, 1 };

here, making 'mask' addressable again.  I have a patch for this in testing.

  parent reply	other threads:[~2022-07-20  9:01 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-20  5:25 [Bug tree-optimization/106365] New: " linkw at gcc dot gnu.org
2022-07-20  7:35 ` [Bug tree-optimization/106365] " linkw at gcc dot gnu.org
2022-07-20  8:25 ` rguenth at gcc dot gnu.org
2022-07-20  8:53 ` linkw at gcc dot gnu.org
2022-07-20  9:01 ` rguenth at gcc dot gnu.org [this message]
2022-07-20  9:07 ` rguenth at gcc dot gnu.org
2022-07-20  9:11 ` linkw at gcc dot gnu.org
2022-07-20 10:34 ` rguenth at gcc dot gnu.org
2022-07-20 12:07 ` rguenth at gcc dot gnu.org
2022-07-21  7:26 ` rguenth at gcc dot gnu.org
2022-07-21  7:30 ` linkw at gcc dot gnu.org
2022-07-21  7:31 ` rguenth at gcc dot gnu.org
2022-07-21  7:37 ` linkw at gcc dot gnu.org
2022-07-21  7:39 ` rguenth at gcc dot gnu.org
2022-07-21  7:57 ` linkw at gcc dot gnu.org
2022-07-21 11:06 ` cvs-commit at gcc dot gnu.org
2022-07-21 11:24 ` rguenth 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-106365-4-PiwhqNDAEl@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).