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

            Bug ID: 128012
           Summary: [14/15/16/17 Regression] Wrong code with vectorisation
                    and abnormal dispatchers
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ktkachov at gcc dot gnu.org
  Target Milestone: ---
            Target: aarch64

Testcase:

void *buf[5];
long o[2];
int out[4];
int in[4] = { 3, 9, 4, 8 };

__attribute__ ((noipa)) void
bar (int x)
{
  if (x)
    __builtin_longjmp (buf, 1);
}

__attribute__ ((noipa)) int
foo (int x)
{
  return x;
}

__attribute__ ((noipa)) void
f (int c, long a, long b)
{
  long x = a, y = b;
  if (__builtin_setjmp (buf) == 0)
    {
      x = a + 1;
      y = b + 2;
      bar (c & 1);
      x = a + 3;
      y = b + 4;
      bar (c & 2);
      x = a + 5;
      y = b + 6;
    }
  o[0] = x;
  o[1] = y;
}
__attribute__ ((noipa)) void
g (int c, int b, int *restrict p, const int *restrict q)
{
  int v = foo (c);
  if (__builtin_setjmp (buf))
    {
      p[0] = b < q[0] ? b : q[0];
      p[1] = b < q[1] ? b : q[1];
      p[2] = b < q[2] ? b : q[2];
      p[3] = b < q[3] ? b : q[3];
      return;
    }
  bar (v);
}

int
main ()
{
  f (1, 10, 20);
  if (o[0] != 11 || o[1] != 22)
    __builtin_abort ();
  f (2, 10, 20);
  if (o[0] != 13 || o[1] != 24)
    __builtin_abort ();
  f (0, 10, 20);
  if (o[0] != 15 || o[1] != 26)
    __builtin_abort ();
  g (1, 5, out, in);
  if (out[0] != 3 || out[1] != 5 || out[2] != 4 || out[3] != 5)
    __builtin_abort ();
  return 0;
}

This aborts on aarch64 at -O3 but passes at -O1. GCC 10 is the last version
that doesn't fail for me.

Reply via email to