<div dir="ltr"><div>Hi,<br><br>Just from personal interest, is there a canonical way in IR+metadata to express "This small constant trip-count loop is desired to be converted into a sequence of vector operations directly"? Ie, mapping a 4 element i32 loop into a linear sequence of <4 x i32> operations. Obviously this may not always be a win, but I'm just wondering if there's a way to communicate this intent and get around the vectorizer-min-trip-count in specially desired cases, or if I should decide to generate vectorized IR directly. (This is in code coming from a DSL which will impliciltly insert annotations, not manually written loops.)<br>
<br>Cheers,<br></div>Dave<br><div> </div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, May 23, 2013 at 5:06 AM, Arnold Schwaighofer <span dir="ltr"><<a href="mailto:aschwaighofer@apple.com" target="_blank">aschwaighofer@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
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.<br>

<br>
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.<br>
<div><div class="h5"><br>
On May 22, 2013, at 10:23 PM, maxs <<a href="mailto:xtxwy.ustc@gmail.com">xtxwy.ustc@gmail.com</a>> wrote:<br>
<br>
> Hi,<br>
>     I have the llvm loop vectorizer to complie the following sample:<br>
> //=================<br>
> int test(int *a, int n) {<br>
><br>
>         for(int i = 0; i < n; i++) {<br>
><br>
>                   a[i] += i;<br>
><br>
>         }<br>
><br>
><br>
>         return 0;<br>
><br>
> }<br>
><br>
> //================<br>
>        The corresponded .ll file has a loop preheader:<br>
> //================<br>
><br>
> <a href="http://for.body.lr.ph" target="_blank">for.body.lr.ph</a>:                                   ; preds = %entry<br>
>   %cnt.cast = zext i32 %n to i64<br>
>   %0 = and i32 %n, 7<br>
>   %n.mod.vf = zext i32 %0 to i64<br>
>   %n.vec = sub i64 %cnt.cast, %n.mod.vf<br>
>   %cmp.zero = icmp eq i32 %0, %n<br>
>   br i1 %cmp.zero, label %middle.block, label %vector.body<br>
> //================<br>
><br>
>        That is , if n <=7, the program will skip the vector.body. In LoopVectorize.cpp , I see the following code:<br>
> //================<br>
><br>
>             static cl::opt<unsigned><br>
>             TinyTripCountVectorThreshold("vectorizer-min-trip-count", cl::init(16), ... );<br>
> //================<br>
><br>
>       The minimal loop count is 16. What is the "n<=7" meaning?   Thanks.<br>
><br>
</div></div>> _______________________________________________<br>
> LLVM Developers mailing list<br>
> <a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
<br>
<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
</blockquote></div><br><br clear="all"><br>-- <br><div>cheers, dave tweed__________________________</div><div>high-performance computing and machine vision expert: <a href="mailto:david.tweed@gmail.com" target="_blank">david.tweed@gmail.com</a></div>
<div>"while having code so boring anyone can maintain it, use Python." -- attempted insult seen on slashdot</div><div> </div>
</div>