[Bug tree-optimization/49795] vectorization of conditional code happens only on local variables
vincenzo.innocente at cern dot ch
gcc-bugzilla@gcc.gnu.org
Wed Jul 20 17:00:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49795
--- Comment #6 from vincenzo Innocente <vincenzo.innocente at cern dot ch> 2011-07-20 16:59:20 UTC ---
actually -ftree-loop-if-convert-stores does the "trick" with -Ofast
things are not fully consistent though
of these four loop I get the following
notice how the combination -ftree-loop-if-convert-stores -03 vectorize the
first BUT not the second!
const int N=1024;
float __attribute__ ((aligned(16))) a[N];
float __attribute__ ((aligned(16))) b[N];
float __attribute__ ((aligned(16))) c[N];
float __attribute__ ((aligned(16))) d[N];
void loop1() {
for (int i=0; i!=N; ++i) {
d[i]=a[i]+b[i];
if (c[i]<0) d[i] = -d[i];
}
}
void loop2() {
for (int i=0; i!=N; ++i) {
float tmp = a[i]+b[i];
if (c[i]<0) tmp = -tmp;
d[i]=tmp;
}
}
void loop3() {
for (int i=0; i!=N; ++i) {
d[i] = (c[i]>0) ? a[i]+b[i] : -a[i]-b[i];
}
}
void loop4() {
for (int i=0; i!=N; ++i) {
float tmp = a[i]+b[i];
tmp = (c[i]>0) ? tmp : -tmp;
d[i] = tmp;
}
}
c++ -Wall -O3 -ftree-vectorizer-verbose=2 -c test/testBug.cpp -o bha.o
test/testBug.cpp:9: note: vectorized 0 loops in function.
test/testBug.cpp:17: note: LOOP VECTORIZED.
test/testBug.cpp:16: note: vectorized 1 loops in function.
test/testBug.cpp:24: note: vectorized 0 loops in function.
test/testBug.cpp:31: note: not vectorized: unsupported data-type bool
test/testBug.cpp:30: note: vectorized 0 loops in function.
pb-d-128-141-131-10:Octave innocent$ c++ -Wall -O3 -ftree-vectorizer-verbose=2
-c test/testBug.cpp -o bha.o -ftree-loop-if-convert-stores
test/testBug.cpp:10: note: LOOP VECTORIZED.
test/testBug.cpp:9: note: vectorized 1 loops in function.
test/testBug.cpp:16: note: vectorized 0 loops in function.
test/testBug.cpp:24: note: vectorized 0 loops in function.
test/testBug.cpp:30: note: vectorized 0 loops in function.
pb-d-128-141-131-10:Octave innocent$ c++ -Wall -Ofast
-ftree-vectorizer-verbose=2 -c test/testBug.cpp -o bha.o
-ftree-loop-if-convert-stores
test/testBug.cpp:10: note: LOOP VECTORIZED.
test/testBug.cpp:9: note: vectorized 1 loops in function.
test/testBug.cpp:17: note: LOOP VECTORIZED.
test/testBug.cpp:16: note: vectorized 1 loops in function.
test/testBug.cpp:25: note: LOOP VECTORIZED.
test/testBug.cpp:24: note: vectorized 1 loops in function.
test/testBug.cpp:31: note: LOOP VECTORIZED.
test/testBug.cpp:30: note: vectorized 1 loops in function.
More information about the Gcc-bugs
mailing list