<div dir="ltr">Hi Arnold,<div><br></div><div>Unfortunately this change doesn't fix the problem.</div><div>I still see messages "LV: Not vectorizing: No #pragma vectorize enable." in debug log.</div><div><br><div class="gmail_extra"><br><div class="gmail_quote">2014-10-27 1:07 GMT+03:00 Arnold Schwaighofer <span dir="ltr"><<a href="mailto:aschwaighofer@apple.com" target="_blank">aschwaighofer@apple.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><br>
r220652 restored the old behavior (defaulting to vectorization) while allowing to disable lto vectorization.<br>
<br>
<br>
<br>
<br>
'disable-lto-vectorization' allows to disable lto vectorization if so desired.<br>
<br>
<br>
<br>
<br>
Alexey could you let me know whether your testcase works again?<br>
<br>
<br>
<br>
<br>
Thanks,<br>
<br>
Arnold<br>
<br>
On 10/24/14, JF Bastien   wrote:<br>
> Yes, cl::opt<bool> defaults to false when there&#39;s no init. Changing the default will affect non-LTO too. This may be the right thing to do, but isn&#39;t my call. Turning it on only for LTO sounds better IMO, but I&#39;m not sure what you&#39;re suggesting: I think there shouldn&#39;t be a vectorization flags that are different for LTO and for non-LTO.<br>
<div><div>><br>
> On Fri, Oct 24, 2014 at 8:57 AM, Arnold Schwaighofer <<a href="mailto:aschwaighofer@apple.com" target="_blank">aschwaighofer@apple.com</a> <<a href="mailto:aschwaighofer@apple.com" target="_blank">aschwaighofer@apple.com</a>>> wrote:<br>
><br>
> > JF are you sure that “LoopVectorize” is set to true by default by the PassManager instance of libLTO?<br>
> ><br>
><br>
> ><br>
> ><br>
><br>
> > The reason why I forced these parameters to true is that this is not the case if I remember correctly.<br>
> ><br>
><br>
> ><br>
> ><br>
><br>
> > We wanted the default for libLTO to be with vectorization.<br>
> ><br>
><br>
> ><br>
> ><br>
><br>
> > PassManager.cpp:<br>
> ><br>
><br>
> ><br>
> ><br>
><br>
> > static cl::opt<bool><br>
> ><br>
><br>
> > RunLoopVectorization("vectorize-loops", cl::Hidden,<br>
> ><br>
><br>
> >                      cl::desc("Run the Loop vectorization passes"));<br>
> ><br>
><br>
> ><br>
> ><br>
><br>
> > PassManagerBuilder::PassManagerBuilder() {<br>
> ><br>
><br>
> >     OptLevel = 2;<br>
> ><br>
><br>
> >     SizeLevel = 0;<br>
> ><br>
><br>
> >     LibraryInfo = nullptr;<br>
> ><br>
><br>
> >     Inliner = nullptr;<br>
> ><br>
><br>
> >     DisableTailCalls = false;<br>
> ><br>
><br>
> >     DisableUnitAtATime = false;<br>
> ><br>
><br>
> >     DisableUnrollLoops = false;<br>
> ><br>
><br>
> >     BBVectorize = RunBBVectorization;<br>
> ><br>
><br>
> >     SLPVectorize = RunSLPVectorization;<br>
> ><br>
><br>
> >     LoopVectorize = RunLoopVectorization;<br>
> ><br>
><br>
> >     RerollLoops = RunLoopRerolling;<br>
> ><br>
><br>
> >     LoadCombine = RunLoadCombine;<br>
> ><br>
><br>
> >     DisableGVNLoadPRE = false;<br>
> ><br>
><br>
> >     VerifyInput = false;<br>
> ><br>
><br>
> >     VerifyOutput = false;<br>
> ><br>
><br>
> >     StripDebug = false;<br>
> ><br>
><br>
> >     MergeFunctions = false;<br>
> ><br>
><br>
> > }<br>
> ><br>
><br>
> ><br>
> ><br>
><br>
> > LTOCodeGenerator.cpp:<br>
> ><br>
><br>
> ><br>
> ><br>
><br>
> > /// Optimize merged modules using various IPO passes<br>
> ><br>
><br>
> > bool LTOCodeGenerator::generateObjectFile(raw_ostream &out,<br>
> ><br>
><br>
> >                                           bool DisableOpt,<br>
> ><br>
><br>
> >                                           bool DisableInline,<br>
> ><br>
><br>
> >                                           bool DisableGVNLoadPRE,<br>
> ><br>
><br>
> >                                           std::string &errMsg) {<br>
> ><br>
><br>
> >   if (!this->determineTarget(errMsg))<br>
> ><br>
><br>
> >     return false;<br>
> ><br>
><br>
> ><br>
> ><br>
><br>
> >   Module *mergedModule = IRLinker.getModule();<br>
> ><br>
><br>
> ><br>
> ><br>
><br>
> >   // Mark which symbols can not be internalized<br>
> ><br>
><br>
> >   this->applyScopeRestrictions();<br>
> ><br>
><br>
> ><br>
> ><br>
><br>
> >   // Instantiate the pass manager to organize the passes.<br>
> ><br>
><br>
> >   PassManager passes;<br>
> ><br>
><br>
> ><br>
> ><br>
><br>
> >   // Add an appropriate DataLayout instance for this module...<br>
> ><br>
><br>
> >   mergedModule->setDataLayout(TargetMach->getSubtargetImpl()->getDataLayout());<br>
> ><br>
><br>
> ><br>
> ><br>
><br>
> >   Triple TargetTriple(TargetMach->getTargetTriple());<br>
> ><br>
><br>
> >   PassManagerBuilder PMB;<br>
> ><br>
><br>
> >   PMB.DisableGVNLoadPRE = DisableGVNLoadPRE;<br>
> ><br>
><br>
> >   if (!DisableInline)<br>
> ><br>
><br>
> >     PMB.Inliner = createFunctionInliningPass();<br>
> ><br>
><br>
> >   PMB.LibraryInfo = new TargetLibraryInfo(TargetTriple);<br>
> ><br>
><br>
> >   if (DisableOpt)<br>
> ><br>
><br>
> >     PMB.OptLevel = 0;<br>
> ><br>
><br>
> >   PMB.VerifyInput = true;<br>
> ><br>
><br>
> >   PMB.VerifyOutput = true;<br>
> ><br>
><br>
> ><br>
> ><br>
><br>
> >   PMB.populateLTOPassManager(passes, TargetMach);<br>
> ><br>
><br>
> ><br>
> ><br>
><br>
> ><br>
> ><br>
><br>
> ><br>
> ><br>
><br>
</div></div>> > I think cl::opt<bool> defaults to false and your commit effectively disabled vectorization during LTO. We can recover this by changing the default cl::opt flags &#39;vectorize-loops’ and &#39;vectorize-slp&#39;  to true. If that does not work (because we make assumption somewhere about the default being false) we can follow the example of “DisableGVNLoadPRE” in LTOCodeGenerator.cpp and a a flag to disable Vectorization during LTO and pass that to the PassManager created in generateObjectFile.<br>
<span>> ><br>
><br>
> ><br>
> ><br>
><br>
> >   PMB.LoopVectorize = !DisableLTOVectorization;<br>
> ><br>
><br>
> ><br>
> ><br>
><br>
> ><br>
> ><br>
><br>
> > Thanks,<br>
> ><br>
><br>
> > Arnold<br>
> ><br>
><br>
> ><br>
> ><br>
><br>
> > > DisableUnrollLoops<br>
> ><br>
><br>
</span><span>> > > On Oct 24, 2014, at 5:27 AM, Alexey Volkov <<a href="mailto:avolkov.intel@gmail.com" target="_blank">avolkov.intel@gmail.com</a> <<a href="mailto:avolkov.intel@gmail.com" target="_blank">avolkov.intel@gmail.com</a>>> wrote:<br>
> ><br>
><br>
> > ><br>
> ><br>
><br>
> > > Hi JF,<br>
> ><br>
><br>
> > ><br>
> ><br>
><br>
> > > After your commit I saw a performance regression because of disabled Loop Vectorizer:<br>
> ><br>
><br>
> > >  LV: Not vectorizing: No #pragma vectorize enable.<br>
> ><br>
><br>
</span>> > > It is really strange since I used -Ofast -flto clang&#39;s options to build an application.<br>
<span>> ><br>
><br>
> > > Before this change loop was successfully vectorized by Loop Vectorizer.<br>
> ><br>
><br>
> > ><br>
> ><br>
><br>
> > > Thanks, Alexey.<br>
> ><br>
><br>
> > ><br>
> ><br>
><br>
</span>> > > 2014-10-22 3:18 GMT+04:00 JF Bastien <<a href="mailto:jfb@google.com" target="_blank">jfb@google.com</a> <<a href="mailto:jfb@google.com" target="_blank">jfb@google.com</a>>>:<br>
<span>> ><br>
><br>
> > > Author: jfb<br>
> ><br>
><br>
> > > Date: Tue Oct 21 18:18:21 2014<br>
> ><br>
><br>
> > > New Revision: 220345<br>
> ><br>
><br>
> > ><br>
> ><br>
><br>
> > > URL: <a href="http://llvm.org/viewvc/llvm-project?rev=220345&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=220345&view=rev</a><br>
> ><br>
><br>
> > > Log:<br>
> ><br>
><br>
> > > LTO: respect command-line options that disable vectorization.<br>
> ><br>
><br>
> > ><br>
> ><br>
><br>
</span>> > > Summary: Patches 202051 and 208013 added calls to LTO&#39;s PassManager which unconditionally add LoopVectorizePass and SLPVectorizerPass instead of following the logic in PassManagerBuilder::populateModulePassManager and honoring the -vectorize-loops -run-slp-after-loop-vectorization flags.<br>
<div><div>> ><br>
><br>
> > ><br>
> ><br>
><br>
> > > Reviewers: nadav, aschwaighofer, yijiang<br>
> ><br>
><br>
> > ><br>
> ><br>
><br>
> > > Subscribers: llvm-commits<br>
> ><br>
><br>
> > ><br>
> ><br>
><br>
> > > Differential Revision: <a href="http://reviews.llvm.org/D5884" target="_blank">http://reviews.llvm.org/D5884</a><br>
> ><br>
><br>
> > ><br>
> ><br>
><br>
> > > Modified:<br>
> ><br>
><br>
> > >     llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp<br>
> ><br>
><br>
> > ><br>
> ><br>
><br>
> > > Modified: llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp<br>
> ><br>
><br>
> > > URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp?rev=220345&r1=220344&r2=220345&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp?rev=220345&r1=220344&r2=220345&view=diff</a><br>
> ><br>
><br>
> > > ==============================================================================<br>
> ><br>
><br>
> > > --- llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp (original)<br>
> ><br>
><br>
> > > +++ llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp Tue Oct 21 18:18:21 2014<br>
> ><br>
><br>
> > > @@ -440,10 +440,12 @@ void PassManagerBuilder::addLTOOptimizat<br>
> ><br>
><br>
> > >    // More loops are countable; try to optimize them.<br>
> ><br>
><br>
> > >    PM.add(createIndVarSimplifyPass());<br>
> ><br>
><br>
> > >    PM.add(createLoopDeletionPass());<br>
> ><br>
><br>
> > > -  PM.add(createLoopVectorizePass(true, true));<br>
> ><br>
><br>
> > > +  PM.add(createLoopVectorizePass(DisableUnrollLoops, LoopVectorize));<br>
> ><br>
><br>
> > ><br>
> ><br>
><br>
> > >    // More scalar chains could be vectorized due to more alias information<br>
> ><br>
><br>
> > > -  PM.add(createSLPVectorizerPass()); // Vectorize parallel scalar chains.<br>
> ><br>
><br>
> > > +  if (RunSLPAfterLoopVectorization)<br>
> ><br>
><br>
> > > +    if (SLPVectorize)<br>
> ><br>
><br>
> > > +      PM.add(createSLPVectorizerPass()); // Vectorize parallel scalar chains.<br>
> ><br>
><br>
> > ><br>
> ><br>
><br>
> > >    // After vectorization, assume intrinsics may tell us more about pointer<br>
> ><br>
><br>
> > >    // alignments.<br>
> ><br>
><br>
> > ><br>
> ><br>
><br>
> > ><br>
> ><br>
><br>
> > > _______________________________________________<br>
> ><br>
><br>
> > > llvm-commits mailing list<br>
> ><br>
><br>
</div></div>> > > <a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a> <<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a>><br>
<span>> ><br>
><br>
> > > <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
> ><br>
><br>
> > ><br>
> ><br>
><br>
> > ><br>
> ><br>
><br>
> > ><br>
> ><br>
><br>
> > > --<br>
> ><br>
><br>
> > > Alexey Volkov<br>
> ><br>
><br>
> > > Intel Corporation<br>
> ><br>
><br>
> > > _______________________________________________<br>
> ><br>
><br>
> > > llvm-commits mailing list<br>
> ><br>
><br>
</span>> > > <a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a> <<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a>><br>
> ><br>
><br>
> > > <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
> ><br>
><br>
> ><br>
> ><br>
><br>
> ><br>
> ><br>
> ><br>
><br>
><br>
><br>
><br>
><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr">Alexey Volkov<div>Intel Corporation</div></div>
</div></div></div>