This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
loop vectorization vs. sequential code vectorization
- From: Vaclav SMILAUER <eudoxos at arcig dot cz>
- To: gcc-help at gcc dot gnu dot org
- Date: Thu, 21 Dec 2006 14:54:34 +0100
- Subject: loop vectorization vs. sequential code vectorization
Hello, I have the following simple code (with gcc 4.1.2 20060928):
volatile double a[3], b[3];
double c[3];
a[0]=.5; a[1]=.5; a[2]=.5;
b[0]=.5; b[1]=.5; b[2]=.5;
// one of the following would be commented out:
// case1
for(int i=0; i<3; i++){c[i]=a[i]*b[i];}
// case2
c[0]=a[0]*b[0]; c[1]=a[1]*b[1]; c[2]=a[2]*b[2];
Now, case1 is vectorized with "-O2 -ftree-vectorize -march=pentium4
-ftree-vectorize-vebose=2", while case2 is not.
My questions are:
1. whether the compiler can be instructed by some option to analyze code
and interpret case2 as if it were a loop and vectorize it.
2. whether this has changed with more recent gcc versions.
Best regards, Vaclav (please cc to me, I am not subscribed)