https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101450
Bug ID: 101450
Summary: GCC doesn't vectorize loop due to evolution of base is
not affine.
Product: gcc
Version: 12.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: ---
Host: x86_64-pc-linux-gnu
the testcase is extracted from coremark
cat test.c
void
matrix_add_const(unsigned int N, short *A, short val)
{
unsigned int i, j;
for (i = 0; i < N; i++)
{
for (j = 0; j < N; j++)
{
A[i * N + j] += val;
}
}
}
gcc failed to vectorize it since there could be wrap for i*N + j, but we can do
multi-versioning for it?
llvm seems does that.
https://godbolt.org/z/Er44ffTE3