<p dir="ltr">Just an FYI: it's often handy to mention the PR number when a thread is concluded by filing a bug. That way other people reading (now, or more importantly, later) can follow the issue through to the bug and its resolution</p>

<div class="gmail_quote">On Apr 11, 2013 4:24 PM, "Anadi Mishra" <<a href="mailto:reachanadi@gmail.com">reachanadi@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Done.<br>
<br>
Best,<br>
Anadi.<br>
<br>
<br>
On Thu, Apr 11, 2013 at 7:01 AM, Nadav Rotem <<a href="mailto:nrotem@apple.com">nrotem@apple.com</a>> wrote:<br>
> Hi Anadi,<br>
><br>
> Yes, this is a bug in the loop vectorizer. The loop vectorizer expects only<br>
> one loop counter (integer with step=1).  There is no reason why we should<br>
> not handle the case below, and it should be easy to fix.  Interestingly<br>
> enough if you reverse the order of iterations and count from SIZE to zero,<br>
> the loop vectorizer would vectorize it.  If you open a bugzilla report and<br>
> assign it to me I will look at it.<br>
><br>
> Example:<br>
><br>
> int foo(int *aa, int *bb, int SIZE) {<br>
>   int count = 190;<br>
>   for(int i=SIZE;i > 0;i--) {<br>
>     aa[i] = bb[i] + count;<br>
>     count++;<br>
>   }<br>
> }<br>
><br>
><br>
> Thanks,<br>
> Nadav<br>
><br>
>   The loop vectorizer has some LSR-like capabilities for merging multiple<br>
> induction variables into a<br>
><br>
><br>
> On Apr 10, 2013, at 7:52 PM, Anadi Mishra <<a href="mailto:reachanadi@gmail.com">reachanadi@gmail.com</a>> wrote:<br>
><br>
> Hi Nadav,<br>
><br>
> I tried your suggestion by changing the condition to :<br>
><br>
> 189   if (LoopVectorize && OptLevel >= 0)<br>
> 190     MPM.add(createLoopVectorizePass());<br>
><br>
> and compiled. Then I used the following command:<br>
><br>
> opt -mtriple=x86_64-linux-gnu -vectorize-loops<br>
> -vectorizer-min-trip-count=6 -debug-only=loop-vectorize -O1-S -o<br>
> example1_vect.s example1.s<br>
><br>
> where example1.s is IR generated by<br>
><br>
> clang -S -emit-llvm example1.c<br>
><br>
> example1.c contains the following loop:<br>
><br>
> for(int i=0;i<SIZE;i++)<br>
>        {<br>
>                aa[i] = bb[i] + count;<br>
>                count++;<br>
>                printf("a[%d] is %d", i,aa[i]);<br>
>        }<br>
><br>
> LV runs and says "LV: Found too many inductions".<br>
><br>
> I am guessing that this because some of the loop passes are missing.<br>
> Could you please shed some light on what passes should be used to<br>
> prepare the IR for LV?<br>
><br>
><br>
> Best,<br>
> Anadi<br>
><br>
><br>
> On Thu, Apr 11, 2013 at 2:48 AM, Nadav Rotem <<a href="mailto:nrotem@apple.com">nrotem@apple.com</a>> wrote:<br>
><br>
><br>
> Hi Anadi,<br>
><br>
> In the file PassManagerBuilder.cpp you can change the lines below to get rid<br>
> of the O3 restriction.<br>
><br>
> 189   if (LoopVectorize && OptLevel > 2)<br>
> 190     MPM.add(createLoopVectorizePass());<br>
><br>
> Nadav<br>
><br>
><br>
><br>
><br>
> On Apr 10, 2013, at 5:39 PM, Anadi Mishra <<a href="mailto:reachanadi@gmail.com">reachanadi@gmail.com</a>> wrote:<br>
><br>
> Hello,<br>
><br>
> I am trying out the LoopVectorizer(LV) pass and would like to decouple it<br>
> from O3 which is currently required to run LV. I want to do this because I<br>
> want to understand the behaviour of LV by trying simple loops but the O3<br>
> mostly optimises away the loop body.<br>
><br>
> Any ideas would be appreciated.<br>
><br>
> Best,<br>
> Anadi.<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>
><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>