summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-12-13 05:15:29 +0000
committerChris Lattner <sabre@nondot.org>2010-12-13 05:15:29 +0000
commit6df7bdd8109313b08c6eecbe26d31cafc06e80dc (patch)
tree990b35a8b0b4a8ef0b8b8858e3b6f3149e0e3113 /llvm/lib/Transforms/Utils/SimplifyCFG.cpp
parent2e3832d9a0c3279084ba0e84a752169954d8fb32 (diff)
downloadbcm5719-llvm-6df7bdd8109313b08c6eecbe26d31cafc06e80dc.tar.gz
bcm5719-llvm-6df7bdd8109313b08c6eecbe26d31cafc06e80dc.zip
move HoistThenElseCodeToIf up to a more logical and efficient-to-handle place.
llvm-svn: 121684
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/SimplifyCFG.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index 52ad1ee0704..7c80a3dd7a4 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -2145,6 +2145,16 @@ bool SimplifyCFGOpt::run(BasicBlock *BB) {
if (SimplifyBranchOnICmpChain(BI, TD))
return true;
+
+ // We have a conditional branch to two blocks that are only reachable
+ // from BI. We know that the condbr dominates the two blocks, so see if
+ // there is any identical code in the "then" and "else" blocks. If so, we
+ // can hoist it up to the branching block.
+ if (BI->getSuccessor(0)->getSinglePredecessor() != 0 &&
+ BI->getSuccessor(1)->getSinglePredecessor() != 0)
+ if (HoistThenElseCodeToIf(BI))
+ return SimplifyCFG(BB) | true;
+
// If this is a branch on a phi node in the current block, thread control
// through this block if any PHI node entries are constants.
if (PHINode *PN = dyn_cast<PHINode>(BI->getCondition()))
@@ -2327,13 +2337,7 @@ bool SimplifyCFGOpt::run(BasicBlock *BB) {
pred_iterator PI = pred_begin(OtherBB);
++PI;
- if (PI == pred_end(OtherBB)) {
- // We have a conditional branch to two blocks that are only reachable
- // from the condbr. We know that the condbr dominates the two blocks,
- // so see if there is any identical code in the "then" and "else"
- // blocks. If so, we can hoist it up to the branching block.
- Changed |= HoistThenElseCodeToIf(BI);
- } else {
+ if (PI != pred_end(OtherBB)) {
BasicBlock* OnlySucc = NULL;
for (succ_iterator SI = succ_begin(BB), SE = succ_end(BB);
SI != SE; ++SI) {
OpenPOWER on IntegriCloud