[llvm] r204188 - [LV] While I'm here, use range based for loops which are so much cleaner

Chandler Carruth chandlerc at gmail.com
Tue Mar 18 15:00:32 PDT 2014


Author: chandlerc
Date: Tue Mar 18 17:00:32 2014
New Revision: 204188

URL: http://llvm.org/viewvc/llvm-project?rev=204188&view=rev
Log:
[LV] While I'm here, use range based for loops which are so much cleaner
for this kind of walk.

Modified:
    llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp

Modified: llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp?rev=204188&r1=204187&r2=204188&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp (original)
+++ llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp Tue Mar 18 17:00:32 2014
@@ -989,12 +989,12 @@ private:
   }
 };
 
-static void addInnerLoop(Loop *L, SmallVectorImpl<Loop *> &V) {
-  if (L->empty())
-    return V.push_back(L);
+static void addInnerLoop(Loop &L, SmallVectorImpl<Loop *> &V) {
+  if (L.empty())
+    return V.push_back(&L);
 
-  for (Loop::iterator I = L->begin(), E = L->end(); I != E; ++I)
-    addInnerLoop(*I, V);
+  for (Loop *InnerL : L)
+    addInnerLoop(*InnerL, V);
 }
 
 /// The LoopVectorize Pass.
@@ -1051,8 +1051,8 @@ struct LoopVectorize : public FunctionPa
     // and can invalidate iterators across the loops.
     SmallVector<Loop *, 8> Worklist;
 
-    for (LoopInfo::iterator I = LI->begin(), E = LI->end(); I != E; ++I)
-      addInnerLoop(*I, Worklist);
+    for (Loop *L : *LI)
+      addInnerLoop(*L, Worklist);
 
     // Now walk the identified inner loops.
     bool Changed = false;





More information about the llvm-commits mailing list