Don't insert nearly as many redundant phi nodes.
[oota-llvm.git] / lib / Transforms / Scalar / LoopUnswitch.cpp
index 6b4d6376f286a7628a757f55bf2957be44a8cb08..f0c09e6d7d7c2eef7216cc3c1a677ac829a649ae 100644 (file)
@@ -425,7 +425,8 @@ static inline void RemapInstruction(Instruction *I,
   }
 }
 
-// CloneDomInfo - NewBB is cloned from Orig basic block. Now clone Dominator Info.
+// CloneDomInfo - NewBB is cloned from Orig basic block. Now clone Dominator
+// Info.
 //
 // If Orig block's immediate dominator is mapped in VM then use corresponding
 // immediate dominator from the map. Otherwise Orig block's dominator is also
@@ -776,8 +777,8 @@ void LoopUnswitch::UnswitchNontrivialCondition(Value *LIC, Constant *Val,
       if (LBBI != DF->end()) {
         DominanceFrontier::DomSetType &LBSet = LBBI->second;
         for (DominanceFrontier::DomSetType::iterator LI = LBSet.begin(),
-               LE = LBSet.end(); LI != LE; ++LI) {
-          BasicBlock *B = *LI;
+               LE = LBSet.end(); LI != LE; /* NULL */) {
+          BasicBlock *B = *LI++;
           if (OutSiders.count(B))
             DF->removeFromFrontier(LBBI, B);
         }
@@ -788,8 +789,8 @@ void LoopUnswitch::UnswitchNontrivialCondition(Value *LIC, Constant *Val,
       if (NBBI != DF->end()) {
         DominanceFrontier::DomSetType NBSet = NBBI->second;
         for (DominanceFrontier::DomSetType::iterator NI = NBSet.begin(),
-               NE = NBSet.end(); NI != NE; ++NI) {
-          BasicBlock *B = *NI;
+               NE = NBSet.end(); NI != NE; /* NULL */) {
+          BasicBlock *B = *NI++;
           if (OutSiders.count(B))
             DF->removeFromFrontier(NBBI, B);
         }
@@ -1113,7 +1114,8 @@ void LoopUnswitch::SimplifyCode(std::vector<Instruction*> &Worklist, Loop *L) {
     switch (I->getOpcode()) {
     case Instruction::Select:
       if (ConstantInt *CB = dyn_cast<ConstantInt>(I->getOperand(0))) {
-        ReplaceUsesOfWith(I, I->getOperand(!CB->getZExtValue()+1), Worklist, L, LPM);
+        ReplaceUsesOfWith(I, I->getOperand(!CB->getZExtValue()+1), Worklist, L,
+                          LPM);
         continue;
       }
       break;