<div dir="ltr"><div>Can you maybe pull this out into a helper to avoid copypasta?</div><div><br></div><div>-- Sean Silva</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Aug 6, 2014 at 5:56 AM, James Molloy <span dir="ltr"><<a href="mailto:james.molloy@arm.com" target="_blank">james.molloy@arm.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: jamesm<br>
Date: Wed Aug  6 07:56:19 2014<br>
New Revision: 214963<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=214963&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=214963&view=rev</a><br>
Log:<br>
Add a new option -run-slp-after-loop-vectorization.<br>
<br>
This swaps the order of the loop vectorizer and the SLP/BB vectorizers. It is disabled by default so we can do performance testing - ideally we want to change to having the loop vectorizer running first, and the SLP vectorizer using its leftovers instead of the other way around.<br>

<br>
<br>
Modified:<br>
    llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp<br>
<br>
Modified: llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp?rev=214963&r1=214962&r2=214963&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp?rev=214963&r1=214962&r2=214963&view=diff</a><br>

==============================================================================<br>
--- llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp (original)<br>
+++ llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp Wed Aug  6 07:56:19 2014<br>
@@ -57,6 +57,13 @@ static cl::opt<bool> RunLoadCombine("com<br>
                                     cl::Hidden,<br>
                                     cl::desc("Run the load combining pass"));<br>
<br>
+static cl::opt<bool><br>
+RunSLPAfterLoopVectorization("run-slp-after-loop-vectorization",<br>
+  cl::init(false), cl::Hidden,<br>
+  cl::desc("Run the SLP vectorizer (and BB vectorizer) after the Loop "<br>
+           "vectorizer instead of before"));<br>
+<br>
+<br>
 PassManagerBuilder::PassManagerBuilder() {<br>
     OptLevel = 2;<br>
     SizeLevel = 0;<br>
@@ -227,21 +234,23 @@ void PassManagerBuilder::populateModuleP<br>
<br>
   if (RerollLoops)<br>
     MPM.add(createLoopRerollPass());<br>
-  if (SLPVectorize)<br>
-    MPM.add(createSLPVectorizerPass());   // Vectorize parallel scalar chains.<br>
-<br>
-  if (BBVectorize) {<br>
-    MPM.add(createBBVectorizePass());<br>
-    MPM.add(createInstructionCombiningPass());<br>
-    addExtensionsToPM(EP_Peephole, MPM);<br>
-    if (OptLevel > 1 && UseGVNAfterVectorization)<br>
-      MPM.add(createGVNPass());           // Remove redundancies<br>
-    else<br>
-      MPM.add(createEarlyCSEPass());      // Catch trivial redundancies<br>
-<br>
-    // BBVectorize may have significantly shortened a loop body; unroll again.<br>
-    if (!DisableUnrollLoops)<br>
-      MPM.add(createLoopUnrollPass());<br>
+  if (!RunSLPAfterLoopVectorization) {<br>
+    if (SLPVectorize)<br>
+      MPM.add(createSLPVectorizerPass());   // Vectorize parallel scalar chains.<br>
+<br>
+    if (BBVectorize) {<br>
+      MPM.add(createBBVectorizePass());<br>
+      MPM.add(createInstructionCombiningPass());<br>
+      addExtensionsToPM(EP_Peephole, MPM);<br>
+      if (OptLevel > 1 && UseGVNAfterVectorization)<br>
+        MPM.add(createGVNPass());           // Remove redundancies<br>
+      else<br>
+        MPM.add(createEarlyCSEPass());      // Catch trivial redundancies<br>
+<br>
+      // BBVectorize may have significantly shortened a loop body; unroll again.<br>
+      if (!DisableUnrollLoops)<br>
+        MPM.add(createLoopUnrollPass());<br>
+    }<br>
   }<br>
<br>
   if (LoadCombine)<br>
@@ -263,6 +272,26 @@ void PassManagerBuilder::populateModuleP<br>
   // as function calls, so that we can only pass them when the vectorizer<br>
   // changed the code.<br>
   MPM.add(createInstructionCombiningPass());<br>
+<br>
+  if (RunSLPAfterLoopVectorization) {<br>
+    if (SLPVectorize)<br>
+      MPM.add(createSLPVectorizerPass());   // Vectorize parallel scalar chains.<br>
+<br>
+    if (BBVectorize) {<br>
+      MPM.add(createBBVectorizePass());<br>
+      MPM.add(createInstructionCombiningPass());<br>
+      addExtensionsToPM(EP_Peephole, MPM);<br>
+      if (OptLevel > 1 && UseGVNAfterVectorization)<br>
+        MPM.add(createGVNPass());           // Remove redundancies<br>
+      else<br>
+        MPM.add(createEarlyCSEPass());      // Catch trivial redundancies<br>
+<br>
+      // BBVectorize may have significantly shortened a loop body; unroll again.<br>
+      if (!DisableUnrollLoops)<br>
+        MPM.add(createLoopUnrollPass());<br>
+    }<br>
+  }<br>
+<br>
   addExtensionsToPM(EP_Peephole, MPM);<br>
   MPM.add(createCFGSimplificationPass());<br>
<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><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>
</blockquote></div><br></div>