public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/114375] New: Wrong vectorization of permuted mask load
@ 2024-03-18 10:23 rguenth at gcc dot gnu.org
  2024-03-18 10:29 ` [Bug tree-optimization/114375] [11/12/13/14 Regression] " rguenth at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-03-18 10:23 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 114375
           Summary: Wrong vectorization of permuted mask load
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rguenth at gcc dot gnu.org
  Target Milestone: ---

I've figured we never end up with a load permutation on .MASK_LOAD SLP nodes,
instead we put one on the mask load only (if that ends up permuted).  It took
me a while to produce a testcase we're happy to vectorize and not by accident
produce correct values.  Here's one:

int a[512];
int b[512];
int c[512];
void __attribute__((noipa))
foo(int * __restrict p)
{
  for (int i = 0; i < 64; ++i)
    {
      int tem = 2, tem2 = 2;
      if (a[4*i + 1])
        tem = p[4*i];
      if (a[4*i])
        tem2 = p[4*i + 2];
      b[2*i] = tem2;
      b[2*i+1] = tem;
      if (a[4*i + 2])
        tem = p[4*i + 1];
      if (a[4*i + 3])
        tem2 = p[4*i + 3];
      c[2*i] = tem2;
      c[2*i+1] = tem;
    }
}
int main()
{
  for (int i = 0; i < 512; ++i)
    a[i] = (i >> 1) & 1;
  foo (a);
  if (c[2] != 1 || c[3] != 0)
    __builtin_abort ();
}

miscompiled on x86_64 with -O3 -mavx2.  Note b[] is correct in the end,
but c[] is { 1, 0, 0, 1, 1, 0, 0, 1, ... } instead of { 1, 0, 1, 0, ... }.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-05-16  9:56 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-18 10:23 [Bug tree-optimization/114375] New: Wrong vectorization of permuted mask load rguenth at gcc dot gnu.org
2024-03-18 10:29 ` [Bug tree-optimization/114375] [11/12/13/14 Regression] " rguenth at gcc dot gnu.org
2024-03-18 12:09 ` rguenth at gcc dot gnu.org
2024-03-19  8:02 ` cvs-commit at gcc dot gnu.org
2024-03-19  8:04 ` [Bug tree-optimization/114375] [11/12/13 " rguenth at gcc dot gnu.org
2024-05-08 12:26 ` rguenth at gcc dot gnu.org
2024-05-08 13:38 ` cvs-commit at gcc dot gnu.org
2024-05-16  9:56 ` [Bug tree-optimization/114375] [11/12 " cvs-commit at gcc dot gnu.org

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