<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div>Hi Chandler, </div><div><br></div><div>Have you had a chance to run the tests that you wanted with the new flag ?  Are you planning to continue the discussion on this issue ?</div><div><br></div><div>Thanks,</div><div>Nadav</div><div><br></div><br><div><div>On Jun 24, 2013, at 12:21 AM, Chandler Carruth <<a href="mailto:chandlerc@gmail.com">chandlerc@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="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;">Author: chandlerc<br>Date: Mon Jun 24 02:21:47 2013<br>New Revision: 184698<br><br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project?rev=184698&view=rev">http://llvm.org/viewvc/llvm-project?rev=184698&view=rev</a><br>Log:<br>Add a flag to defer vectorization into a phase after the inliner and its<br>CGSCC pass manager. This should insulate the inlining decisions from the<br>vectorization decisions, however it may have both compile time and code<br>size problems so it is just an experimental option right now.<br><br>Adding this based on a discussion with Arnold and it seems at least<br>worth having this flag for us to both run some experiments to see if<br>this strategy is workable. It may solve some of the regressions seen<br>with the loop vectorizer.<br><br>Modified:<br>   llvm/trunk/include/llvm/Transforms/IPO/PassManagerBuilder.h<br>   llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp<br><br>Modified: llvm/trunk/include/llvm/Transforms/IPO/PassManagerBuilder.h<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/IPO/PassManagerBuilder.h?rev=184698&r1=184697&r2=184698&view=diff">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/IPO/PassManagerBuilder.h?rev=184698&r1=184697&r2=184698&view=diff</a><br>==============================================================================<br>--- llvm/trunk/include/llvm/Transforms/IPO/PassManagerBuilder.h (original)<br>+++ llvm/trunk/include/llvm/Transforms/IPO/PassManagerBuilder.h Mon Jun 24 02:21:47 2013<br>@@ -105,6 +105,7 @@ public:<br>  bool BBVectorize;<br>  bool SLPVectorize;<br>  bool LoopVectorize;<br>+  bool LateVectorize;<br><br>private:<br>  /// ExtensionList - This is list of all of the extensions that are registered.<br><br>Modified: llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp?rev=184698&r1=184697&r2=184698&view=diff">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp?rev=184698&r1=184697&r2=184698&view=diff</a><br>==============================================================================<br>--- llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp (original)<br>+++ llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp Mon Jun 24 02:21:47 2013<br>@@ -33,6 +33,11 @@ RunLoopVectorization("vectorize-loops",<br>                     cl::desc("Run the Loop vectorization passes"));<br><br>static cl::opt<bool><br>+LateVectorization("late-vectorize", cl::init(false), cl::Hidden,<br>+                  cl::desc("Run the vectorization pasess late in the pass "<br>+                           "pipeline (after the inliner)"));<br>+<br>+static cl::opt<bool><br>RunSLPVectorization("vectorize-slp",<br>                    cl::desc("Run the SLP vectorization passes"));<br><br>@@ -59,6 +64,7 @@ PassManagerBuilder::PassManagerBuilder()<br>    BBVectorize = RunBBVectorization;<br>    SLPVectorize = RunSLPVectorization;<br>    LoopVectorize = RunLoopVectorization;<br>+    LateVectorize = LateVectorization;<br>}<br><br>PassManagerBuilder::~PassManagerBuilder() {<br>@@ -189,8 +195,8 @@ void PassManagerBuilder::populateModuleP<br>  MPM.add(createLoopIdiomPass());             // Recognize idioms like memset.<br>  MPM.add(createLoopDeletionPass());          // Delete dead loops<br><br>-  if (LoopVectorize && OptLevel > 1 && SizeLevel < 2)<br>-    MPM.add(createLoopVectorizePass());<br>+  if (!LateVectorize && LoopVectorize && OptLevel > 1 && SizeLevel < 2)<br>+      MPM.add(createLoopVectorizePass());<br><br>  if (!DisableUnrollLoops)<br>    MPM.add(createLoopUnrollPass());          // Unroll small loops<br>@@ -210,26 +216,70 @@ void PassManagerBuilder::populateModuleP<br><br>  addExtensionsToPM(EP_ScalarOptimizerLate, MPM);<br><br>-  if (SLPVectorize)<br>-    MPM.add(createSLPVectorizerPass());     // Vectorize parallel scalar chains.<br>-<br>-  if (BBVectorize) {<br>-    MPM.add(createBBVectorizePass());<br>-    MPM.add(createInstructionCombiningPass());<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 (!LateVectorize) {<br>+    if (SLPVectorize)<br>+      MPM.add(createSLPVectorizerPass());   // Vectorize parallel scalar chains.<br>+<br>+    if (BBVectorize) {<br>+      MPM.add(createBBVectorizePass());<br>+      MPM.add(createInstructionCombiningPass());<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>  MPM.add(createAggressiveDCEPass());         // Delete dead instructions<br>  MPM.add(createCFGSimplificationPass());     // Merge & remove BBs<br>  MPM.add(createInstructionCombiningPass());  // Clean up after everything.<br><br>+  // As an experimental mode, run any vectorization passes in a separate<br>+  // pipeline from the CGSCC pass manager that runs iteratively with the<br>+  // inliner.<br>+  if (LateVectorize) {<br>+    // FIXME: This is a HACK! The inliner pass above implicitly creates a CGSCC<br>+    // pass manager that we are specifically trying to avoid. To prevent this<br>+    // we must insert a no-op module pass to reset the pass manager.<br>+    MPM.add(createBarrierNoopPass());<br>+<br>+    // Add the various vectorization passes and relevant cleanup passes for<br>+    // them since we are no longer in the middle of the main scalar pipeline.<br>+    if (LoopVectorize && OptLevel > 1 && SizeLevel < 2) {<br>+      MPM.add(createLoopVectorizePass());<br>+<br>+      if (!DisableUnrollLoops)<br>+        MPM.add(createLoopUnrollPass());    // Unroll small loops<br>+<br>+      // FIXME: Is this necessary/useful? Should we also do SimplifyCFG?<br>+      MPM.add(createInstructionCombiningPass());<br>+    }<br>+<br>+    if (SLPVectorize) {<br>+      MPM.add(createSLPVectorizerPass());   // Vectorize parallel scalar chains.<br>+<br>+      // FIXME: Is this necessary/useful? Should we also do SimplifyCFG?<br>+      MPM.add(createInstructionCombiningPass());<br>+    }<br>+<br>+    if (BBVectorize) {<br>+      MPM.add(createBBVectorizePass());<br>+      MPM.add(createInstructionCombiningPass());<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 (!DisableUnitAtATime) {<br>    // FIXME: We shouldn't bother with this anymore.<br>    MPM.add(createStripDeadPrototypesPass()); // Get rid of dead prototypes<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">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a></div></blockquote></div><br></body></html>