[LLVMdev] LLVM Loop Vectorizer puzzle
Arnold Schwaighofer
aschwaighofer at apple.com
Wed May 22 21:06:16 PDT 2013
Hi,
The TinyTripCountVectorThreshold only applies to loops with a known (constant) trip count. If a loop has a trip count below this value we don’t attempt to vectorize the loop. The loop below has an unknown trip count.
Once we decide to vectorize a loop, we emit code to check whether we can execute one iteration of the vectorized body. This is the code quoted below.
On May 22, 2013, at 10:23 PM, maxs <xtxwy.ustc at gmail.com> wrote:
> Hi,
> I have the llvm loop vectorizer to complie the following sample:
> //=================
> int test(int *a, int n) {
>
> for(int i = 0; i < n; i++) {
>
> a[i] += i;
>
> }
>
>
> return 0;
>
> }
>
> //================
> The corresponded .ll file has a loop preheader:
> //================
>
> for.body.lr.ph: ; preds = %entry
> %cnt.cast = zext i32 %n to i64
> %0 = and i32 %n, 7
> %n.mod.vf = zext i32 %0 to i64
> %n.vec = sub i64 %cnt.cast, %n.mod.vf
> %cmp.zero = icmp eq i32 %0, %n
> br i1 %cmp.zero, label %middle.block, label %vector.body
> //================
>
> That is , if n <=7, the program will skip the vector.body. In LoopVectorize.cpp , I see the following code:
> //================
>
> static cl::opt<unsigned>
> TinyTripCountVectorThreshold("vectorizer-min-trip-count", cl::init(16), ... );
> //================
>
> The minimal loop count is 16. What is the "n<=7" meaning? Thanks.
>
> _______________________________________________
> 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