http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49513
Summary: introducing a product inhibit vectorization
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: tree-optimization
AssignedTo: [email protected]
ReportedBy: [email protected]
in the simple example below the first loop vectorize, the second not
I'm using
gcc version 4.7.0 20110528 (experimental) (GCC)
#include<cmath>
float __attribute__ ((aligned(16))) a[1024];
float __attribute__ ((aligned(16))) s[1024];
float __attribute__ ((aligned(16))) c[1024];
inline float bar(float y, float x ){
float xx = fabs(x);
float yy = fabs(y);
float tmp =0.0f;
if (yy>xx) {
tmp = yy;
yy=xx; xx=tmp;
}
float t=yy/xx;
return t;
}
void foo1() {
for (int i=0; i!=1024; ++i) {
float z = i;
a[i] = bar(s[i],c[i]);
}
}
void foo2() {
for (int i=0; i!=1024; ++i) {
float z = i;
a[i] = bar(z*s[i],z*c[i]);
}
}
c++ -std=c++0x -Ofast -c vectBug.cc -ftree-vectorizer-verbose=7
vectBug.cc:21: note: vect_model_load_cost: aligned.
vectBug.cc:21: note: vect_get_data_access_cost: inside_cost = 1, outside_cost =
0.
vectBug.cc:21: note: vect_model_load_cost: aligned.
vectBug.cc:21: note: vect_get_data_access_cost: inside_cost = 2, outside_cost =
0.
vectBug.cc:21: note: vect_model_store_cost: aligned.
vectBug.cc:21: note: vect_get_data_access_cost: inside_cost = 3, outside_cost =
0.
vectBug.cc:21: note: vect_model_load_cost: aligned.
vectBug.cc:21: note: vect_model_load_cost: inside_cost = 1, outside_cost = 0 .
vectBug.cc:21: note: vect_model_load_cost: aligned.
vectBug.cc:21: note: vect_model_load_cost: inside_cost = 1, outside_cost = 0 .
vectBug.cc:21: note: vect_model_simple_cost: inside_cost = 1, outside_cost = 0
.
vectBug.cc:21: note: vect_model_simple_cost: inside_cost = 1, outside_cost = 0
.
vectBug.cc:21: note: vect_model_simple_cost: inside_cost = 1, outside_cost = 0
.
vectBug.cc:21: note: vect_model_store_cost: aligned.
vectBug.cc:21: note: vect_model_store_cost: inside_cost = 1, outside_cost = 0 .
vectBug.cc:21: note: Cost model analysis:
Vector inside of loop cost: 6
Vector outside of loop cost: 0
Scalar iteration cost: 8
Scalar outside cost: 0
prologue iterations: 0
epilogue iterations: 0
Calculated minimum iters for profitability: 1
vectBug.cc:21: note: Profitability threshold = 3
vectBug.cc:21: note: LOOP VECTORIZED.
vectBug.cc:20: note: vectorized 1 loops in function.
vectBug.cc:27: note: not vectorized: control flow in loop.
vectBug.cc:26: note: vectorized 0 loops in function.