[LLVMdev] Question about the loop vectorizer

Nadav Rotem nrotem at apple.com
Sun Jan 13 16:47:50 PST 2013


Hi Michael, 

Thanks for trying the Loop Vectorizer.  All of the loops in the examples you sent are vectorized in LLVM ToT.  On Sanybridge, example2 is vectorized to 8 x float (YMM registers) and is unrolled twice. I imagine that 3.2 is too old.

Thanks,
Nadav



On Jan 13, 2013, at 4:35 PM, Michael Lam <michael.lam.sk at gmail.com> wrote:

> Hi all,
> 
> I have a question about the loop vectorizer.
> 
> For the following code:
> 
> void example1 (float a[], float b[], float c[], int n) {
>    int i;
>    for (i=0; i<n; i++){
>        a[i] = c[i];
>    }
>    for (i=0; i<n; i++){
>        a[i] += b[i];
>    }
> }
> 
> void example2 (float a[], float b[], float c[], int n) {
>    int i;
>    for (i=0; i<n; i++){
>        a[i] = b[i] + c[i];
>    }
> }
> 
> 
> The two functions are doing the same thing.  But only example1 is
> vectorized.  Is there a reason for not vectorizing example2?  Or, is
> it simply a feature not available in llvm3.2?
> 
> Regards,
> Siu
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




More information about the llvm-dev mailing list