[Bug tree-optimization/101842] New: Vectorizer doesn't vectorize when loop bound depends on two independent variables that are unknown
tnfchris at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Aug 10 09:41:11 GMT 2021
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101842
Bug ID: 101842
Summary: Vectorizer doesn't vectorize when loop bound depends
on two independent variables that are unknown
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: tnfchris at gcc dot gnu.org
Target Milestone: ---
The following example
float f(float *p, float d, int len, float lim)
{
float m[4];
for (int i = 0; i < len && d >= lim; i += 4)
{
m[0] = p[0] * p[0];
m[1] = p[1] * p[1];
m[2] = p[2] * p[2];
m[3] = p[3] * p[3];
d = d - m[0];
d = d - m[1];
d = d - m[2];
d = d - m[3];
p += 4;
}
return d;
}
isn't vectorized at -Ofast because
```
missed: not vectorized: number of iterations cannot be computed.
```
which seems odd because I would expect that it would be treated as just any
other loop with unbounded iterations. Commenting out this check results in it
bailing out because of it not knowing how to deal with the reduction.
This loop should be easy to vectorize with vectorizing the multiplications of m
and then reducing the changes of `d - sum (m[0..3])`.
More information about the Gcc-bugs
mailing list