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

            Bug ID: 93868
           Summary: [10 Regression] wrong-code with permuted SLP reduction
           Product: gcc
           Version: 10.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: ---

The SLP graph representation made vect_attempt_slp_rearrange_stmts unsafe since
it fails to verify the permutation it applies only affects the SLP reduction.

unsigned a[1024];
unsigned b[1024];

void __attribute__((noipa))
foo (unsigned *q, unsigned *r)
{
  unsigned sum1 = 0, sum2 = 0;
  for (int i = 0; i < 512; ++i)
    {
      sum1 += a[2*i];
      sum2 += a[2*i+1];
      b[2*i] = a[2*i+1];
      b[2*i+1] = a[2*i];
    }
  *q = sum1;
  *r = sum2;
}

int main()
{
  unsigned sum1, sum2;
  a[0] = 0;
  a[1] = 1;
  foo (&sum1, &sum2);
  if (b[0] != 1 || b[1] != 0)
    __builtin_abort ();
  return 0;
}

Reply via email to