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

            Bug ID: 108916
           Summary: Miss vectorization for masked gather w/o restrict
                    qualifier.
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: crazylht at gmail dot com
  Target Milestone: ---

void
foo1 (double* __restrict a, long long* b, double* c, long long* d)
{
    for (long long i = 0; i != 10000; i++)
      {
        if (b[i])
          a[i] = 0;
        else
          a[i] = c[d[i]];
      }
}


void
foo2 (double* __restrict a, long long* b, double* __restrict c, long long* d)
{
    for (long long i = 0; i != 10000; i++)
      {
        if (b[i])
          a[i] = 0;
        else
          a[i] = c[d[i]];
      }
}

w/ -Ofast -march=skylake-avx512, foo1 can't be vectorized, but foo2 can, the
only difference between foo1 and foo2 is restrict qualifier for double* c.
But there's already a restrict qualifier for double* __restrict a in both
cases,   why double* __restrict c matters.

Reply via email to