Auto-vectorization in GCC 4.0

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Auto-vectorization in GCC 4.0

Zhiru Zhang
Hi,
I am trying to turn on the new GCC auto-vectorization feature within llvmgcc4. Below is the command I used, but nothing was vectorized. Does it mean that llvmgcc4 has disabled this optimization and all I can do is to embed SSE intrinsics in the source code by hand?
 
Thanks!
 
./llvm-gcc4-x86/bin/llvm-gcc -c -O2 -ftree-vectorize -msse -ftree-vectorizer-verbose=5 -emit-llvm vec.c -o vec.bc
 
////////////////////vec.c/////////////////////////
int a[256], b[256], c[256];
foo () {
  int i;
  for (i=0; i<256; i++){
    a[i] = b[i] + c[i];
  }
}
 
 

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: Auto-vectorization in GCC 4.0

Devang Patel
llvmgcc4 emits LLVM byte code before executing GCC optimizations, so one can say that llvmgcc4 disables all GCC optimizations.

On Jul 31, 2006, at 11:01 AM, Zhiru Zhang wrote:

Hi,
I am trying to turn on the new GCC auto-vectorization feature within llvmgcc4. Below is the command I used, but nothing was vectorized. Does it mean that llvmgcc4 has disabled this optimization and all I can do is to embed SSE intrinsics in the source code by hand?
 
Thanks!
 
./llvm-gcc4-x86/bin/llvm-gcc -c -O2 -ftree-vectorize -msse -ftree-vectorizer-verbose=5 -emit-llvm vec.c -o vec.bc
 
////////////////////vec.c/////////////////////////
int a[256], b[256], c[256];
foo () {
  int i;
  for (i=0; i<256; i++){
    a[i] = b[i] + c[i];
  }
}
 
 
_______________________________________________
LLVM Developers mailing list

-
Devang




_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: Auto-vectorization in GCC 4.0

Vikram S. Adve-2
Does llvmgcc4 convert the high-level AST to LLVM (like llvmgcc3x) or  
does it go from GIMPL to LLVM?  If the latter, would it be possible  
to allow some TreeSSA optimizations before emitting LLVM?

--Vikram
http://www.cs.uiuc.edu/~vadve
http://llvm.cs.uiuc.edu/


On Jul 31, 2006, at 1:10 PM, Devang Patel wrote:

> llvmgcc4 emits LLVM byte code before executing GCC optimizations,  
> so one can say that llvmgcc4 disables all GCC optimizations.
>
> On Jul 31, 2006, at 11:01 AM, Zhiru Zhang wrote:
>
>> Hi,
>> I am trying to turn on the new GCC auto-vectorization feature  
>> within llvmgcc4. Below is the command I used, but nothing was  
>> vectorized. Does it mean that llvmgcc4 has disabled this  
>> optimization and all I can do is to embed SSE intrinsics in the  
>> source code by hand?
>>
>> Thanks!
>>
>> ./llvm-gcc4-x86/bin/llvm-gcc -c -O2 -ftree-vectorize -msse -ftree-
>> vectorizer-verbose=5 -emit-llvm vec.c -o vec.bc
>>
>> ////////////////////vec.c/////////////////////////
>> int a[256], b[256], c[256];
>> foo () {
>>   int i;
>>   for (i=0; i<256; i++){
>>     a[i] = b[i] + c[i];
>>   }
>> }
>>
>>
>> _______________________________________________
>> LLVM Developers mailing list
>> [hidden email]         http://llvm.cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
> -
> Devang
>
>
>
> _______________________________________________
> LLVM Developers mailing list
> [hidden email]         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: Auto-vectorization in GCC 4.0

Devang Patel

On Jul 31, 2006, at 11:14 AM, Vikram Adve wrote:

> Does llvmgcc4 convert the high-level AST to LLVM (like llvmgcc3x)  
> or does it go from GIMPL to LLVM?  If the latter, would it be  
> possible to allow some TreeSSA optimizations before emitting LLVM?

llvmgcc4 intercepts high-level GCC trees to GIMPLE tree  
transformation routines to get trees that are suitable for LLVM byte  
code. And TreeSSA optimizer may not be able to handle LLVM suitable  
GIMPLE trees. One such case is how Array references are handled (&a
[i] vs a+i*size). However, I do not know exact details of LLVM byte  
code generation work inside llvmgcc4.

-
Devang

>
> --Vikram
> http://www.cs.uiuc.edu/~vadve
> http://llvm.cs.uiuc.edu/
>
>
> On Jul 31, 2006, at 1:10 PM, Devang Patel wrote:
>
>> llvmgcc4 emits LLVM byte code before executing GCC optimizations,  
>> so one can say that llvmgcc4 disables all GCC optimizations.
>>
>> On Jul 31, 2006, at 11:01 AM, Zhiru Zhang wrote:
>>
>>> Hi,
>>> I am trying to turn on the new GCC auto-vectorization feature  
>>> within llvmgcc4. Below is the command I used, but nothing was  
>>> vectorized. Does it mean that llvmgcc4 has disabled this  
>>> optimization and all I can do is to embed SSE intrinsics in the  
>>> source code by hand?
>>>
>>> Thanks!
>>>
>>> ./llvm-gcc4-x86/bin/llvm-gcc -c -O2 -ftree-vectorize -msse -ftree-
>>> vectorizer-verbose=5 -emit-llvm vec.c -o vec.bc
>>>
>>> ////////////////////vec.c/////////////////////////
>>> int a[256], b[256], c[256];
>>> foo () {
>>>   int i;
>>>   for (i=0; i<256; i++){
>>>     a[i] = b[i] + c[i];
>>>   }
>>> }
>>>
>>>
>>> _______________________________________________
>>> LLVM Developers mailing list
>>> [hidden email]         http://llvm.cs.uiuc.edu
>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>>
>> -
>> Devang
>>
>>
>>
>> _______________________________________________
>> LLVM Developers mailing list
>> [hidden email]         http://llvm.cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
> _______________________________________________
> LLVM Developers mailing list
> [hidden email]         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

-
Devang



_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: Auto-vectorization in GCC 4.0

Chris Lattner
On Mon, 31 Jul 2006, Devang Patel wrote:
> On Jul 31, 2006, at 11:14 AM, Vikram Adve wrote:
>>  Does llvmgcc4 convert the high-level AST to LLVM (like llvmgcc3x) or does
>>  it go from GIMPL to LLVM?  If the latter, would it be possible to allow
>>  some TreeSSA optimizations before emitting LLVM?
> llvmgcc4 intercepts high-level GCC trees to GIMPLE tree transformation
> routines to get trees that are suitable for LLVM byte code. And TreeSSA
> optimizer may not be able to handle LLVM suitable GIMPLE trees. One such case
> is how Array references are handled (&a[i] vs a+i*size). However, I do not
> know exact details of LLVM byte code generation work inside llvmgcc4.

Another issue is that gimple has various different forms (high gimple, low
gimple, and several other minor forms).  We work on "high gimple", so
optimizations that require low gimple or later forms won't work.  I don't
know what the gcc vectorizor uses, but IIRC it runs late in the pipeline,
so it probably is low-gimple.

I don't think the gimple->llvm translator can't handle low gimple, but it
may be possible to extend it.

-Chris

>>  On Jul 31, 2006, at 1:10 PM, Devang Patel wrote:
>>
>> >  llvmgcc4 emits LLVM byte code before executing GCC optimizations, so one
>> >  can say that llvmgcc4 disables all GCC optimizations.
>> >
>> >  On Jul 31, 2006, at 11:01 AM, Zhiru Zhang wrote:
>> >
>> > >  Hi,
>> > >  I am trying to turn on the new GCC auto-vectorization feature within
>> > >  llvmgcc4. Below is the command I used, but nothing was vectorized.
>> > >  Does it mean that llvmgcc4 has disabled this optimization and all I
>> > >  can do is to embed SSE intrinsics in the source code by hand?
>> > >
>> > >  Thanks!
>> > >
>> > >  ./llvm-gcc4-x86/bin/llvm-gcc -c -O2 -ftree-vectorize -msse -ftree-
>> > >  vectorizer-verbose=5 -emit-llvm vec.c -o vec.bc
>> > >
>> > >  ////////////////////vec.c/////////////////////////
>> > >  int a[256], b[256], c[256];
>> > >  foo () {
>> > >    int i;
>> > >    for (i=0; i<256; i++){
>> > >     a[i] = b[i] + c[i];
>> > >   }
>> > >  }
>> > >
>> > >
>> > >  _______________________________________________
>> > >  LLVM Developers mailing list
>> > >  [hidden email]         http://llvm.cs.uiuc.edu
>> > >  http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>> >
>> >  -
>> >  Devang
>> >
>> >
>> >
>> >  _______________________________________________
>> >  LLVM Developers mailing list
>> >  [hidden email]         http://llvm.cs.uiuc.edu
>> >  http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>>
>>  _______________________________________________
>>  LLVM Developers mailing list
>>  [hidden email]         http://llvm.cs.uiuc.edu
>>  http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
> -
> Devang
>
>
>
> _______________________________________________
> LLVM Developers mailing list
> [hidden email]         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>

-Chris

--
http://nondot.org/sabre/
http://llvm.org/
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: Auto-vectorization in GCC 4.0

Devang Patel

On Jul 31, 2006, at 11:42 AM, Chris Lattner wrote:

> On Mon, 31 Jul 2006, Devang Patel wrote:
>> On Jul 31, 2006, at 11:14 AM, Vikram Adve wrote:
>>>  Does llvmgcc4 convert the high-level AST to LLVM (like  
>>> llvmgcc3x) or does  it go from GIMPL to LLVM?  If the latter,  
>>> would it be possible to allow  some TreeSSA optimizations before  
>>> emitting LLVM?
>> llvmgcc4 intercepts high-level GCC trees to GIMPLE tree  
>> transformation routines to get trees that are suitable for LLVM  
>> byte code. And TreeSSA optimizer may not be able to handle LLVM  
>> suitable GIMPLE trees. One such case is how Array references are  
>> handled (&a[i] vs a+i*size). However, I do not know exact details  
>> of LLVM byte code generation work inside llvmgcc4.
>
> Another issue is that gimple has various different forms (high  
> gimple, low gimple, and several other minor forms).  We work on  
> "high gimple", so optimizations that require low gimple or later  
> forms won't work.  I don't know what the gcc vectorizor uses, but  
> IIRC it runs late in the pipeline, so it probably is low-gimple.

Yes, it is low-gimple.

>
> I don't think the gimple->llvm translator can't handle low gimple,  
> but it may be possible to extend it.
>
> -Chris
-
Devang



_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev