This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: version of gcc and auto-vectorization
- From: Ian Lance Taylor <iant at google dot com>
- To: ranjith kumar <ranjit_kumar_b4u at yahoo dot co dot uk>
- Cc: gcc-help at gcc dot gnu dot org
- Date: 20 Mar 2007 12:37:06 -0700
- Subject: Re: version of gcc and auto-vectorization
- References: <20070320174615.21590.qmail@web27401.mail.ukl.yahoo.com>
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