version of gcc and auto-vectorization
Ian Lance Taylor
iant@google.com
Tue Mar 20 20:15:00 GMT 2007
ranjith kumar <ranjit_kumar_b4u@yahoo.co.uk> writes:
> What does auto-vectorization mean??
> I think it must be converting 'for' loops which does
> not exploit SIMD features of a processor(say Pentium
> 4) to 'for' loops which exploit SIMD features(of
> course, it could be at any intermediate
> representation).
Yes, that is what it means.
> I have taken vect-40.c in that directory and compiled
> as "gcc -march=pentium4 -S -O3 -ftree-vectorize
> vect-40.c". I looked at the assembly code. No
> MMX/SSE/SSE2 instructions were there.
> (I have gcc-4.1.2 installed in my P.C. and my
> processor is Pentium4.)
>
> What can gcc do? Can it produce MMX/SSE/SSE2
> instructions even if the source file(.c) does not use
> any functions defined in
> mmintrin.h/xmmintrin.h/emmintrin.h????
Yes, it can.
Here is an example which vectorizes for me with gcc 4.1.2 with -O2
-ftree-vectorize -std=c99 -march=pentium4
void
foo (int n, int * restrict c, const int * restrict a, const int * restrict b)
{
int i;
for (i = 0; i < n; ++i)
c[i] = a[i] + b[i];
}
Ian
More information about the Gcc-help
mailing list