[LLVMdev] Loop vectorizer dosen't find loop bounds

Frank Winter fwinter at jlab.org
Mon Oct 28 12:06:20 PDT 2013


I am trying to vectorize the function

void bar(float *c, float *a, float *b)
{
   const int width = 256;
   for (int i = 0 ; i < 256 ; ++i ) {
     c[ i ]         = a[ i ]         + b[ i ];
     c[ width + i ] = a[ width + i ] + b[ width + i ];
   }
}

using the following commands

clang -emit-llvm -S loop.c
opt loop.ll -O3 -debug-only=loop-vectorize -S -o -

LV: Checking a loop in "bar"
LV: Found a loop: for.body
LV: Found an induction variable.
LV: Found an unidentified write ptr: float* %c
LV: Found an unidentified write ptr: float* %c
LV: Found an unidentified read ptr: float* %a
LV: Found an unidentified read ptr: float* %b
LV: Found an unidentified read ptr: float* %a
LV: Found an unidentified read ptr: float* %b
LV: Found a runtime check ptr:  %arrayidx4 = getelementptr inbounds 
float* %c, i64 %indvars.iv
LV: Found a runtime check ptr:  %arrayidx14 = getelementptr inbounds 
float* %c, i64 %2
LV: Found a runtime check ptr:  %arrayidx = getelementptr inbounds 
float* %a, i64 %indvars.iv
LV: Found a runtime check ptr:  %arrayidx2 = getelementptr inbounds 
float* %b, i64 %indvars.iv
LV: Found a runtime check ptr:  %arrayidx7 = getelementptr inbounds 
float* %a, i64 %2
LV: Found a runtime check ptr:  %arrayidx10 = getelementptr inbounds 
float* %b, i64 %2
LV: We need to do 10 pointer comparisons.
LV: We can't vectorize because we can't find the array bounds.
LV: Can't vectorize due to memory conflicts
LV: Not vectorizing.

Is there any chance to make this work?

Frank




More information about the llvm-dev mailing list