<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Yaduveer,<div class=""><br class=""></div><div class="">Vectorizer probably fails because it expects a loop in a certain form, and to convert a loop to this form one need to run some other passes first. For example, when you run “opt -O3”, the following passes are invoked:</div><div class=""><i class=""><font size="1" class="">-targetlibinfo -tti -no-aa -tbaa -scoped-noalias -assumption-cache-tracker -basicaa -ipsccp -globalopt -deadargelim -domtree -instcombine -simplifycfg -basiccg -prune-eh -inline-cost -inline -functionattrs -argpromotion -sroa -domtree -early-cse -lazy-value-info -jump-threading -correlated-propagation -simplifycfg -domtree -instcombine -tailcallelim -simplifycfg -reassociate -domtree -loops -loop-simplify -lcssa -loop-rotate -licm -loop-unswitch -instcombine -scalar-evolution -loop-simplify -lcssa -indvars -loop-idiom -loop-deletion -loop-unroll -memdep -mldst-motion -domtree -memdep -gvn -memdep -memcpyopt -sccp -domtree -bdce -instcombine -lazy-value-info -jump-threading -correlated-propagation -domtree -memdep -dse -loops -loop-simplify -lcssa -licm -adce -simplifycfg -domtree -instcombine -barrier -float2int -domtree -loops -loop-simplify -lcssa -loop-rotate -branch-prob -block-freq -scalar-evolution -loop-accesses<b class=""> -loop-vectorize</b> -instcombine -scalar-evolution -slp-vectorizer -simplifycfg -domtree -instcombine -loops -loop-simplify -lcssa -scalar-evolution -loop-unroll -instsimplify -loop-simplify -lcssa -licm -scalar-evolution -alignment-from-assumptions -strip-dead-prototypes -globaldce -constmerge -verify</font></i></div><div class=""><br class=""></div><div class="">To get this list, you can use the following command:</div><div class=""><font face="Menlo" class="">llvm-as < /dev/null | opt -O3 -disable-output -debug-pass=Arguments</font></div><div class=""><br class=""></div><div class="">Now, when you get a list of passes to run before the vectorizer, you need to get ‘unoptimized’ IR and run the passes on it - that should give you IR just before the vectorizer.</div><div class=""><br class=""></div><div class="">To get the unoptimized IR, you could use</div><div class=""><font face="Menlo" class="">clang -O3 -mllvm -disable-llvm-optzns -emit-llvm your_source.c -S -o unoptimized_ir.ll</font></div><div class="">(Please note that we use “-O3 -mllvm -disable-llvm-optzns”, not just “-O0” - that allows us to run analysis passes, but not transformations)</div><div class=""><br class=""></div><div class="">Now you run ‘opt’ with passes preceding the vectorizer to get IR before vectorization:</div><div class=""><font face="Menlo" class="">opt -targetlibinfo -tti -no-aa -tbaa …… -scalar-evolution -loop-accesses unoptimized_ir.ll -S -o ir_before_loop_vectorize.ll</font></div><div class="">(you might want to remove verifier passes from the list)</div><div class=""><br class=""></div><div class="">And after this you are ready to run the vectorizer:</div><div class=""><font face="Menlo" class="">opt -loop-vectorize ir_before_loop_vectorize.ll -S -o ir_after_loop_vectorize.ll</font></div><div class=""><br class=""></div><div class="">Hopefully, that’ll resolve the issues you are facing.</div><div class=""><br class=""></div><div class="">Thanks,</div><div class="">Michael</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><div><blockquote type="cite" class=""><div class="">On May 3, 2015, at 9:18 AM, yaduveer singh <<a href="mailto:yaduveer99@gmail.com" class="">yaduveer99@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Hi Michael,<div class=""><br class=""></div><div class="">I tried running my sample C program using "LoopVectorizePass" but I was not able to get the output as I was expecting. Every time I got the message </div><div class="">"LV: Not vectorizing: Cannot prove legality."</div><div class=""><br class=""></div><div class="">Following is the scenario.</div><div class=""><br class=""></div><div class="">c-code</div><div class=""><br class=""></div><div class=""><div class="">#include <stdio.h></div><div class="">int main()</div><div class="">{</div><div class=""><span class="" style="white-space:pre"> </span>int i;</div><div class=""><span class="" style="white-space:pre"> </span>int a=2;</div><div class=""><span class="" style="white-space:pre"> </span>int sum=0;</div><div class=""><span class="" style="white-space:pre"> </span>int arr[400];</div><div class=""><br class=""></div><div class=""><span class="" style="white-space:pre"> </span>for(i=0;i<400;i=i+1)</div><div class=""><span class="" style="white-space:pre"> </span>{</div><div class=""><span class="" style="white-space:pre"> </span>arr[i]=a+i;</div><div class=""><span class="" style="white-space:pre"> </span>sum+=arr[i]; </div><div class=""><span class="" style="white-space:pre"> </span>}</div><div class=""><span class="" style="white-space:pre"> </span>printf("Everything is Done for 1d\n");</div><div class=""><span class="" style="white-space:pre"> </span>return 0;</div><div class="">}</div></div><div class=""><br class=""></div><div class="">following are my command:</div><div class=""><br class=""></div><div class=""><div class="">yaduveer@yaduveer-Inspiron-3542:~/RP$ clang -S -emit-llvm loop1d.c</div><div class="">yaduveer@yaduveer-Inspiron-3542:~/RP$ clang -c -emit-llvm loop1d.c</div><div class="">yaduveer@yaduveer-Inspiron-3542:~/RP$ opt -loop-vectorize -force-vector-width=4 -mem2reg -loop-rotate -indvars -debug -stats loop1d.ll | llvm-dis -o loop1dv1.ll</div></div><div class=""><br class=""></div><div class="">we found the following message on the terminal:(Attached is the details found on terminal and the 2 .ll files)</div><div class=""><br class=""></div><div class=""><div class="">LV: Checking a loop in "main" from loop1d.ll</div><div class="">LV: Loop hints: force=? width=4 unroll=0</div><div class="">LV: Not vectorizing: Cannot prove legality.</div></div><div class=""><br class=""></div><div class="">so can you please let me know if I am following correct steps.</div><div class="">If not, please guide me.</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Thanks in advance.</div><div class=""><br class=""></div><div class="gmail_extra"><br clear="all" class=""><div class=""><div class="gmail_signature"><div dir="ltr" class="">Regards,<div class="">Yaduveer</div></div></div></div>
<br class=""><div class="gmail_quote">On Sun, May 3, 2015 at 12:32 AM, yaduveer singh <span dir="ltr" class=""><<a href="mailto:yaduveer99@gmail.com" target="_blank" class="">yaduveer99@gmail.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="">Hi Michael,<div class=""><br class=""></div><div class="">Thank you very much! </div><div class="">I will try this.</div><div class="gmail_extra"><br class=""></div><div class="gmail_extra">Regards,</div><div class="gmail_extra">Yaduveer</div><div class=""><div class="h5"><div class="gmail_extra"><br class=""></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Sun, May 3, 2015 at 12:11 AM, Michael Zolotukhin <span dir="ltr" class=""><<a href="mailto:mzolotukhin@apple.com" target="_blank" class="">mzolotukhin@apple.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Yaduveer,<br class="">
<br class="">
As far as I remember, unroller in LoopVectorizer pass does what you want to achieve (look for a message "LV: Trying to at least unroll the loops.” to locate this in the code).<br class="">
<br class="">
Michael<br class="">
<div class=""><div class=""><br class="">
> On May 2, 2015, at 9:00 AM, yaduveer singh <<a href="mailto:yaduveer99@gmail.com" target="_blank" class="">yaduveer99@gmail.com</a>> wrote:<br class="">
><br class="">
> Hi Zhoulai,<br class="">
><br class="">
> I am trying to modify "LoopUnrollPass" in llvm which produces multiple<br class="">
> copies of loop equal to the loop unroll factor.Currently, using multicore<br class="">
> architecture, say 3 for example and the execution goes like:<br class="">
><br class="">
> for 3 cores if there are 9 iterations of loop<br class="">
> core instruction<br class="">
> 1 0,3,6<br class="">
> 2 1,4,7<br class="">
> 3 2,5,8<br class="">
><br class="">
> But I want to to modify such that it can execute in following way:<br class="">
><br class="">
> core instruction<br class="">
> 1 0,1,2<br class="">
> 2 3,4,5<br class="">
> 3 6,7,8<br class="">
><br class="">
> I am not able to get where to modify for this. I tried creating a sample<br class="">
> pass using original LoopUnrollPass code and run "make", I received<br class="">
> following error:<br class="">
><br class="">
> loopunrollp.cpp:210:1: error: ‘void<br class="">
> llvm::initializeLoopUnrollpPass(llvm::PassRegistry&)’ should have been<br class="">
> declared inside ‘llvm’<br class="">
> /bin/rm: cannot remove<br class="">
> `/home/yaduveer/RP/LLVM/llvm/lib/Transforms/loopunrollp/Debug+Asserts/loopunrollp.d.tmp':<br class="">
> No such file or directory<br class="">
><br class="">
><br class="">
> Please help<br class="">
><br class="">
> Thanks,<br class="">
> Yaduveer<br class="">
><br class="">
</div></div>> _______________________________________________<br class="">
> LLVM Developers mailing list<br class="">
> <a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank" class="">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu/" target="_blank" class="">http://llvm.cs.uiuc.edu</a><br class="">
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank" class="">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br class="">
<br class="">
</blockquote></div><br class=""></div></div></div></div>
</blockquote></div><br class=""></div></div>
<span id="cid:4EC63AB7-C619-420B-AF11-480436D98E6F@apple.com"><messageOnCommandLine.txt></span><span id="cid:7F60C87A-8753-45EF-A782-4E9B897FEC02@apple.com"><loop1d.c></span><span id="cid:7C325EB7-5D60-49F7-BE4A-F938D827C2E0@apple.com"><loop1d.ll></span><span id="cid:BE97B8C3-D0FB-4F7F-A68B-C9DDA54D02A5@apple.com"><loop1dv1.ll></span></div></blockquote></div><br class=""></div></body></html>