https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120906
Bug ID: 120906
Summary: vectorizer create redudant permutation for reversed
access of array
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: liuhongt at gcc dot gnu.org
Target Milestone: ---
cat test.c
extern int c[32000], d[32000];
void s1113()
{
for (int i = 32000; i >= 0; i--) {
c[i] = d[i] + 1;
}
}
with -march=x86-64-v3 -O3, dump of optimized
<bb 3> [local count: 1063004408]:
# ivtmp.44_17 = PHI <ivtmp.44_18(3), 0(2)>
# DEBUG i => NULL
# DEBUG BEGIN_STMT
vect__1.33_25 = MEM <vector(8) int> [(int *)&d + 127972B + ivtmp.44_17 * 1];
vect__1.34_26 = VEC_PERM_EXPR <vect__1.33_25, vect__1.33_25, { 7, 6, 5, 4, 3,
2, 1, 0 }>;
vect__2.35_27 = vect__1.34_26 + { 1, 1, 1, 1, 1, 1, 1, 1 };
vect__2.38_31 = VEC_PERM_EXPR <vect__2.35_27, vect__2.35_27, { 7, 6, 5, 4, 3,
2, 1, 0 }>;
MEM <vector(8) int> [(int *)&c + 127972B + ivtmp.44_17 * 1] = vect__2.38_31;
# DEBUG BEGIN_STMT
# DEBUG i => NULL
# DEBUG BEGIN_STMT
ivtmp.44_18 = ivtmp.44_17 + 18446744073709551584;
if (ivtmp.44_18 != 18446744073709423616)
goto <bb 3>; [98.99%]
the 2 vec_perm_expr are redundant