Reverting 49056 due to the build being broken.
[oota-llvm.git] / lib / Transforms / Scalar / LoopIndexSplit.cpp
index 48b45351a0f7988e5940d3a6e61f13323493e6ec..8053554c17c12d13764797c19c224ada0dc5a4e5 100644 (file)
@@ -232,8 +232,8 @@ bool LoopIndexSplit::runOnLoop(Loop *IncomingLoop, LPPassManager &LPM_Ref) {
     return false;
 
   // First see if it is possible to eliminate loop itself or not.
-  for (SmallVector<SplitInfo, 4>::iterator SI = SplitData.begin();
-       SI != SplitData.end();) {
+  for (SmallVector<SplitInfo, 4>::iterator SI = SplitData.begin(),
+         E = SplitData.end(); SI != E;) {
     SplitInfo &SD = *SI;
     ICmpInst *CI = dyn_cast<ICmpInst>(SD.SplitCondition);
     if (SD.SplitCondition->getOpcode() == Instruction::And) {
@@ -244,7 +244,8 @@ bool LoopIndexSplit::runOnLoop(Loop *IncomingLoop, LPPassManager &LPM_Ref) {
         return Changed;
       } else {
         SmallVector<SplitInfo, 4>::iterator Delete_SI = SI;
-        SI = SplitData.erase(Delete_SI);
+        ++SI;
+        SplitData.erase(Delete_SI);
       }
     }
     else if (CI && CI->getPredicate() == ICmpInst::ICMP_EQ) {
@@ -255,7 +256,8 @@ bool LoopIndexSplit::runOnLoop(Loop *IncomingLoop, LPPassManager &LPM_Ref) {
         return Changed;
       } else {
         SmallVector<SplitInfo, 4>::iterator Delete_SI = SI;
-        SI = SplitData.erase(Delete_SI);
+        ++SI;
+        SplitData.erase(Delete_SI);
       }
     } else
       ++SI;