aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils/SimplifyCFG.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-05-02 05:02:03 +0000
committerChris Lattner <sabre@nondot.org>2004-05-02 05:02:03 +0000
commit12fe2b1b82fe825d023f40a98931381e84fbc9d3 (patch)
tree95697e4dddd44c1ef8ab7840495339e768d98a78 /lib/Transforms/Utils/SimplifyCFG.cpp
parent6e1ef199ab2c439546b8efb168a91b012c026906 (diff)
Do not infinitely "unroll" single BB loops.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13315 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r--lib/Transforms/Utils/SimplifyCFG.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp b/lib/Transforms/Utils/SimplifyCFG.cpp
index a1b917ff3e..a5153d65e3 100644
--- a/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/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