SLP: When searching for vectorization opportunities scan the blocks in post-order...
authorNadav Rotem <nrotem@apple.com>
Wed, 26 Jun 2013 23:44:45 +0000 (23:44 +0000)
committerNadav Rotem <nrotem@apple.com>
Wed, 26 Jun 2013 23:44:45 +0000 (23:44 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185041 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Vectorize/SLPVectorizer.cpp

index 3c1dc78bc4046a2114b87d4a36aae5f5621804cb..6ffd34bbf5ab0210f16d3b2f07e8b2baa97a54f6 100644 (file)
@@ -1377,8 +1377,10 @@ struct SLPVectorizer : public FunctionPass {
     // he store instructions.
     FuncSLP R(&F, SE, DL, TTI, AA, LI, DT);
 
-    for (Function::iterator it = F.begin(), e = F.end(); it != e; ++it) {
-      BasicBlock *BB = it;
+    // Scan the blocks in the function in post order.
+    for (po_iterator<BasicBlock*> it = po_begin(&F.getEntryBlock()),
+         e = po_end(&F.getEntryBlock()); it != e; ++it) {
+      BasicBlock *BB = *it;
 
       // Vectorize trees that end at reductions.
       Changed |= vectorizeChainsInBlock(BB, R);