[LLVMdev] Loop vectorizer dosen't find loop bounds
Hal Finkel
hfinkel at anl.gov
Mon Oct 28 12:11:23 PDT 2013
----- Original Message -----
> 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?
Try adding the restrict keyword to the function parameters:
void bar(float * restrict c, float * restrict a, float * restrict b)
-Hal
>
> Frank
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
--
Hal Finkel
Assistant Computational Scientist
Leadership Computing Facility
Argonne National Laboratory
More information about the llvm-dev
mailing list