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

--- Comment #17 from Martin Liška <marxin at gcc dot gnu.org> ---
(In reply to rsand...@gcc.gnu.org from comment #16)
> Created attachment 45526 [details]
> Passing testcase
> 
> I'm still not sure where the problem is coming in.  The loop in the vector
> dump looks functionally correct now I've had change to look at it more
> (contrary to my initial comment on IRC).  It seems to be equivalent to the
> attached, which passed on an AVX2 box I found I had accesss to.

But it fails on a skylake-avx512 machine. Minimal test-case that fails:

$ cat avx.c
struct s { unsigned long a, b, c; };

void __attribute__ ((noipa))
f (struct s *restrict s1, struct s *restrict s2, int n)
{
  for (int i = 0; i < n; ++i)
    {
      s1[i].b = s2[i].b;
      s1[i].c = s2[i].c;
      s2[i].c = 0;
    }
}

#define N 6

int
main (void)
{
  struct s s1[N], s2[N];
  for (unsigned int j = 0; j < 6; ++j)
  {
          s2[j].a = j * 5;
          s2[j].b = j * 5 + 2;
          s2[j].c = j * 5 + 4;
  }
  f (s1, s2, 6);
  for (unsigned int j = 0; j < 6; ++j)
          if (s1[j].b != j * 5 + 2)
          {
                  __builtin_printf ("wrong at: %d: is %d, should be %d\n", j,
s1[j].b, j * 5 + 2);
                  __builtin_abort ();
          }

__builtin_printf ("OK\n");
  return 0;
}

$ gcc -march=skylake-avx512 avx.c -g && ./a.out  && gcc -march=skylake-avx512
avx.c -g -O3 && ./a.out 
OK
wrong at: 3: is 15, should be 17
Aborted (core dumped)

Reply via email to