[Bug tree-optimization/71271] New: SLP loop vectorized twice
alahay01 at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed May 25 08:17:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71271
Bug ID: 71271
Summary: SLP loop vectorized twice
Product: gcc
Version: 7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: alahay01 at gcc dot gnu.org
Target Milestone: ---
Created attachment 38559
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=38559&action=edit
Vectorizer pass output
Consider the following code, compiled with -O3 -fno-common:
__attribute__ ((noinline)) int
liveloop (int start, int n, int *x, int *y)
{
int i = start;
int n0, n1, n2, n3;
int j;
for (j = 0; j < n; ++j)
{
i += 1;
n0 = x[(j*4)];
n1 = x[(j*4)+1];
n2 = x[(j*4)+2];
n3 = x[(j*4)+3];
y[(j*4)] = n0 +1;
y[(j*4)+1] = n1 +2;
y[(j*4)+2] = n2 +7;
y[(j*4)+3] = n3 +9;
}
return 0;
}
The vectorizer pass will split the loop using versioning (due to alias
dependencies). One version will be vectorized using SLP, the second will be
kept in scalar form.
However, the slp1 pass will then SLP vectorize the second scalar loop.
This results in the final assembler output containing two versions of the loop,
both of which are vectorized and are almost identical.
Whilst (i think) the code is correct, the code is not ideal.
Tested on x86 and aarch64.
More information about the Gcc-bugs
mailing list