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

            Bug ID: 100848
           Summary: Cases that require -fallow-store-data-races
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rsandifo at gcc dot gnu.org
  Target Milestone: ---

If a loop could be vectorised with -fallow-store-data-races, that approach
trumps IFN_MASK_LOAD/STORE even if -fallow-store-data-races is off.

This means that, in the following example, we can vectorise f2
with -O3 -march=armv8.2-a+sve, but we can't vectorise f1 without
-fallow-store-data-races:

int x[100], y[100];

void f1 (void)
{
  for (int i = 0; i < 100; ++i)
    if (x[i])
      y[i] += 1;
}

void f2 (int *restrict x, int *restrict y)
{
  for (int i = 0; i < 100; ++i)
    if (x[i])
      y[i] += 1;
}

Even if -fallow-store-data-races is passed, it would be better
to avoid load, select and store in the data-races version of:

int x[100], y[100];

void f1 (void)
{
  for (int i = 0; i < 100; ++i)
    if (x[i])
      y[i] = 1;
}

when a single IFN_MASK_STORE is enough.

Reply via email to