remove use of Instruction::getNext
authorChris Lattner <sabre@nondot.org>
Tue, 17 Apr 2007 17:47:54 +0000 (17:47 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 17 Apr 2007 17:47:54 +0000 (17:47 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36199 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Utils/SimplifyCFG.cpp

index 4ee51039ced7aa53fd4f08cc5c98a52f3abec852..f4dc8a98400b7a218e135e1118eece4809968fb0 100644 (file)
@@ -1447,10 +1447,11 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
       // predecessor and use logical operations to pick the right destination.
       BasicBlock *TrueDest  = BI->getSuccessor(0);
       BasicBlock *FalseDest = BI->getSuccessor(1);
-      if (Instruction *Cond = dyn_cast<Instruction>(BI->getCondition()))
+      if (Instruction *Cond = dyn_cast<Instruction>(BI->getCondition())) {
+        BasicBlock::iterator CondIt = Cond;
         if ((isa<CmpInst>(Cond) || isa<BinaryOperator>(Cond)) &&
             Cond->getParent() == BB && &BB->front() == Cond &&
-            Cond->getNext() == BI && Cond->hasOneUse() &&
+            &*++CondIt == BI && Cond->hasOneUse() &&
             TrueDest != BB && FalseDest != BB)
           for (pred_iterator PI = pred_begin(BB), E = pred_end(BB); PI!=E; ++PI)
             if (BranchInst *PBI = dyn_cast<BranchInst>((*PI)->getTerminator()))
@@ -1496,8 +1497,9 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
                   return SimplifyCFG(BB) | 1;
                 }
               }
+      }
 
-      // Scan predessor blocks for conditional branchs.
+      // Scan predessor blocks for conditional branches.
       for (pred_iterator PI = pred_begin(BB), E = pred_end(BB); PI != E; ++PI)
         if (BranchInst *PBI = dyn_cast<BranchInst>((*PI)->getTerminator()))
           if (PBI != BI && PBI->isConditional()) {