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

--- Comment #2 from Andrew Stubbs <ams at gcc dot gnu.org> ---
I have a patch that fixes these things, but somehow there's still a problem
with the incoming parameters from the middle-end.

This testcase (generated by Claude) reproduces the issue on aarch64 with -O2
-ffast-math -march=armv8.3-a (I ran it on QEMU):

/* { dg-do run } */
/* { dg-additional-options "-ffast-math" } */

__attribute__((noipa)) void
f (_Complex double *restrict c, _Complex double *restrict x,
   _Complex double *restrict y, int n, int s)
{
  for (int i = 0; i < n; i++)
    c[i * s] -= x[i] * y[i];
}

int
main (void)
{
  _Complex double x[4], y[4], c[4];
  for (int i = 0; i < 4; i++)
    {
      x[i] = (i + 1) + (i + 2) * 1.0i;
      y[i] = (i + 3) + (i + 4) * 1.0i;
      c[i] = 100 + 50 * 1.0i;
    }

  f (c, x, y, 4, 1);

  for (int i = 0; i < 4; i++)
    if (c[i] != 100 + 50 * 1.0i - x[i] * y[i])
      __builtin_abort ();
  return 0;
}

The strides here are intended to prevent using the ld2 patterns that seem to
work on aarch64, but GCN does not have, thus demonstrating the issue on both.

Reply via email to