[clang] [llvm] Disable pre-link LTO vectorisation and loop unroll for at O2 and O3 optimisation levels (PR #195886)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 4 03:53:47 PST 2026
yafet-a wrote:
> JFYI this commit had caused (before it was reverted) significant performance regressions (up to 112%) in our nighty testing. Some loops stoped being vectorized.
@momchil-velikov I've attached some reproducers based on some of the workloads that were regressing for us in case it helps when relanding the PR. Both are fine at 937a55a2 and regress at e3c929c8 on Neoverse V2.
The first loop is no longer vectorised (~1.9x slower):
```c
long get_n(void);
long get_reps(void);
void kernel(double *restrict x, const double *restrict y,
const double *restrict z, double q, double r, double t) {
const long n = get_n(), reps = get_reps();
for (volatile int rep = 0; rep < reps; ++rep)
for (long i = 0; i < n; ++i)
x[i] = q + y[i] * (r * z[i + 10] + t * z[i + 11]);
}
```
```sh
clang -O3 -flto -fuse-ld=lld -mcpu=neoverse-v2 -shared -fPIC vec.c -o vec.so && llvm-objdump -d --disassemble-symbols=kernel vec.so
```
In the second, the value stored in the previous iteration is reloaded from memory each iteration (~50% slower):
```c
#define N 256
extern float a[N][N], b[N][N], c[N * N];
void sink(void);
void kernel(int reps) {
for (int rep = 0; rep < reps; rep++) {
int k = 1;
for (int i = 0; i < N; i++) {
for (int j = 1; j < N; j++) {
a[j][i] = a[j - 1][i] + c[k - 1] * b[j][i];
++k;
}
++k;
}
sink();
}
}
```
```sh
clang -O3 -ffast-math -flto -fuse-ld=lld -mcpu=neoverse-v2 -shared -fPIC reload.c -o reload.so && llvm-objdump -d --disassemble-symbols=kernel reload.so
```
cc: @eastig
https://github.com/llvm/llvm-project/pull/195886
More information about the cfe-commits
mailing list