diff options
author | Chris Lattner <sabre@nondot.org> | 2004-05-02 05:02:03 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-05-02 05:02:03 +0000 |
commit | 51a6dbcb65706baae0462d6030f79d499cb6e148 (patch) | |
tree | dc74d9d344515a1bf40e920dd3bc814261ea9461 /llvm/lib | |
parent | 2ad4878d8e84da93ff3d24441580f5ebc177130b (diff) | |
download | bcm5719-llvm-51a6dbcb65706baae0462d6030f79d499cb6e148.tar.gz bcm5719-llvm-51a6dbcb65706baae0462d6030f79d499cb6e148.zip |
Do not infinitely "unroll" single BB loops.
llvm-svn: 13315
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index a1b917ff3e9..a5153d65e32 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -804,12 +804,12 @@ bool llvm::SimplifyCFG(BasicBlock *BB) { // If this basic block is ONLY a setcc and a branch, and if a predecessor // branches to us and one of our successors, fold the setcc into the // 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 (Cond->getParent() == BB && &BB->front() == Cond && - Cond->getNext() == BI && Cond->hasOneUse()) { - BasicBlock *TrueDest = BI->getSuccessor(0); - BasicBlock *FalseDest = BI->getSuccessor(1); - + Cond->getNext() == 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())) if (PBI->isConditional() && SafeToMergeTerminators(BI, PBI)) { @@ -853,7 +853,6 @@ bool llvm::SimplifyCFG(BasicBlock *BB) { return SimplifyCFG(BB) | 1; } } - } // If this block ends with a branch instruction, and if there is one // predecessor, see if the previous block ended with a branch on the same |