llvm / llvm/llvm-project

Harmful vectorization after changes in getAddressAccessSCEV

Open
#186,979 0 comments 0 reactions 0 assignees View on GitHub
llvm:SCEV performance regression:22 vectorizers
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Hello,

Commit of changes from PR #171204 caused a performance regression of the benchmarks we are tracking.

The reproducer is as follows (should be compiled w/ -Ofast --target=aarch64-unknown-linux-gnu -mcpu=neoverse-v2):

```c++
__attribute__((aligned(64))) double a[32000];
__attribute__((aligned(64))) double b[32000];
__attribute__((aligned(64))) double c[32000];
__attribute__((aligned(64))) double d[32000];

__attribute__((noinline))
void dummy(double* a, double* b, double* c, double* d)
{
asm volatile("" : : "r"(a), "r"(b), "r"(c), "r"(d) : "memory");
}

void kernel_1(int iterations)
{
int j, k;
for (int nl = 0; nl < 2 * iterations; nl++) {
j = -1;
for (int i = 0; i < 16000; i++) {
k = j + 1;
a[i] = b[k] - d[i];
j = k + 1;
b[k] = a[i] + c[k];
}
dummy(a, b, c, d);
}
}

void kernel_2(int iterations)
{
for (int nl = 0; nl < 2 * iterations; nl++) {
for (int i = 0; i < 16000; i++) {
a[2*i] = c[i] * b[i] + d[i] * b[i] + c[i] * c[i] + d[i] * b[i] + d[i] * c[i];
}
dummy(a, b, c, d);
}
}
```

The commit causes vector.body loops to be created in both kernels, and their performance is degraded.

@fhahn, could you please have a look?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.