http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45833
Summary: Unnecessary runtime versioning for aliasing
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P3
Component: tree-optimization
AssignedTo: [email protected]
ReportedBy: [email protected]
CC: [email protected]
union U { unsigned char c[32]; unsigned short s[16]; };
void
foo (union U *d, union U *s)
{
int i;
for (i = 0; i < 16; i++)
d->s[i] += s->s[i];
}
void
bar (union U *d, union U *s)
{
d->s[0] += s->s[0];
d->s[1] += s->s[1];
d->s[2] += s->s[2];
d->s[3] += s->s[3];
d->s[4] += s->s[4];
d->s[5] += s->s[5];
d->s[6] += s->s[6];
d->s[7] += s->s[7];
d->s[8] += s->s[8];
d->s[9] += s->s[9];
d->s[10] += s->s[10];
d->s[11] += s->s[11];
d->s[12] += s->s[12];
d->s[13] += s->s[13];
d->s[14] += s->s[14];
d->s[15] += s->s[15];
}
has in foo unnecessary runtime versioning for aliasing, even when we should be
able to conclude that either d == s (but that is fine for vectorizing it, as
the result is stored after the sources are read), or d->s[0] ... d->s[15]
doesn't overlap with s->s[0] ... s->s[15].
test.c:7: note: === vect_analyze_dependences ===
test.c:7: note: dependence distance = 0.
test.c:7: note: dependence distance == 0 between d_3(D)->s[i_14] and
d_3(D)->s[i_14]
test.c:7: note: versioning for alias required: can't determine dependence
between s_5(D)->s[i_14] and d_3(D)->s[i_14]
test.c:7: note: mark for run-time aliasing test between s_5(D)->s[i_14] and
d_3(D)->s[i_14]
In bar SLP isn't done, although when adding __restrict qualifiers it is done.