<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On Aug 7, 2016, at 3:33 PM, Alex Susu <<a href="mailto:alex.e.susu@gmail.com" class="">alex.e.susu@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class=""> Hello.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class=""> Michael, thank you for your answer - indeed, your command generates only 1 vector.body.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class=""> I give the following commands to compile:</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class=""> $(LLVM_PATH)/clang -fvectorize -mllvm -force-vector-width=8 src.c -S -emit-llvm</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class=""> $(LLVM_PATH)/opt -debug -O3 -loop-vectorize -force-vector-width=8 src.ll -S >3better_after_opt.ll</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class=""> $(LLVM_PATH)/llc -print-after-all -debug -march=connex -O0 -asm-show-inst -asm-verbose src_after_opt.ll</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""></div></blockquote><div>Hi Alex,</div><div><br class=""></div>I assume you run these three commands to model a clang's O3 behavior using opt? If so, then it’s better to do it the following way:</div><div><br class=""></div><div>1. Generate IR with clang before optimizations kick in:</div><div>clang -O3 -mllvm -disable-llvm-optzns -S -emit-llvm src.c -o src_noopt.ll</div><div><br class=""></div><div>2. Run opt on it:</div><div>opt -O3 src_noopt.ll -S -o src_after_opt.ll </div><div>You can also pass you custom flags here, like “-force-vector-width=8”. No need to pass -loop-vectorize, as it’s already present in O3 pipeline. I guess passing it along with O3 might be the reason you see two vector bodies (e.g. remainder loop might have been vectorized by the second invocation of vectorizer).</div><div><br class=""></div><div>3. Run llc if you need an asm file:</div><div>llc src_after_opt.ll -o src.s -march=connex -asm-show-inst -asm-verbose</div><div><br class=""></div><div>Michael</div><div><br class=""><blockquote type="cite" class=""><div class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class=""> I'd like to mention I am using the version of LoopVectorize.cpp from beginning of Jul 2016.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class=""> Best regards,</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class=""> Alex</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">On 8/6/2016 2:15 AM, Michael Zolotukhin wrote:</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">Hi Alex,<br class=""><br class="">How do you compile this program? I compile it as follows, and don’t see extra vector-bodies:<br class=""><br class=""><blockquote type="cite" class="">bin/clang -O3 vec.c -S -o - |grep "##"<br class=""></blockquote><br class=""> _foo: ## @foo<br class=""> ## BB#0: ## %entry<br class=""> ## BB#1: ## %for.body.preheader<br class=""> ## BB#8: ## %min.iters.checked<br class=""> ## BB#9: ## %vector.memcheck<br class=""> ## BB#10: ## %vector.memcheck<br class=""> ## BB#11: ## %vector.body.preheader<br class=""> ## BB#12: ## %vector.body.prol<br class=""> LBB0_13: ## %vector.body.prol.loopexit<br class=""> ## BB#14: ## %vector.body.preheader.new<br class=""> LBB0_15: ## %vector.body<br class=""> ## =>This Inner Loop Header: Depth=1<br class=""> LBB0_16: ## %middle.block<br class=""> LBB0_2: ## %for.body.preheader27<br class=""> ## BB#3: ## %for.body.prol.preheader<br class=""> LBB0_4: ## %for.body.prol<br class=""> ## =>This Inner Loop Header: Depth=1<br class=""> LBB0_5: ## %for.body.prol.loopexit<br class=""> ## BB#6: ## %for.body.preheader27.new<br class=""> LBB0_7: ## %for.body<br class=""> ## =>This Inner Loop Header: Depth=1<br class=""> LBB0_17: ## %for.cond.cleanup<br class=""><br class=""><br class=""><br class="">Best regards,<br class="">Michael<br class=""><br class=""><br class=""><blockquote type="cite" class="">On Jul 31, 2016, at 5:29 PM, Alex Susu <<a href="mailto:alex.e.susu@gmail.com" class="">alex.e.susu@gmail.com</a><br class=""><<a href="mailto:alex.e.susu@gmail.com" class="">mailto:alex.e.susu@gmail.com</a>>> wrote:<br class=""><br class="">Hello.<br class=""> Mikhail, with the more recent version of the LoopVectorize.cpp code (retrieved at the<br class="">beginning of July 2016) I ran the following piece of C code:<br class=""> void foo(long *A, long *B, long *C, long N) {<br class=""> for (long i = 0; i < N; ++i) {<br class=""> C[i] = A[i] + B[i];<br class=""> }<br class=""> }<br class=""><br class=""> The vectorized LLVM program I obtain contains 2 vector.body blocks - one named<br class="">"vector.body" and the other "vector.body34" for example. The code seems correct - the<br class="">first "vector.body" block is responsible for the vector add of a number of vector<br class="">elements multiple of VF * UF. There are 2 epilogues which makes things a bit strange - I<br class="">am still trying to understand the code.<br class=""><br class=""><br class=""> Is it possible to explain to me where in LoopVectorize.cpp are created 2 vector.body<br class="">blocks? I know that InnerLoopVectorizer::vectorize() calls<br class="">InnerLoopVectorizer::createEmptyLoop() which creates the blocks required for<br class="">vectorization, but I have difficulties to follow the classes instantiations.<br class=""> I ask because in fact, I would prefer having only one "vector.body" block for the<br class="">above C program, as it was happening with LoopVectorize.cpp version of Nov 2015.<br class=""><br class="">Thank you very much,<br class=""> Alex</blockquote></blockquote></div></blockquote></div><br class=""></body></html>