[LLVMdev] Question about the loop vectorizer

Michael Lam michael.lam.sk at gmail.com
Sun Jan 13 16:35:06 PST 2013


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



More information about the llvm-dev mailing list