diff options
author | Chris Lattner <sabre@nondot.org> | 2010-12-13 05:20:28 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-12-13 05:20:28 +0000 |
commit | 466f54ffcf43c1a9ccc2cca0785abf99f468ad6e (patch) | |
tree | cc264284d11e943263496d8679fe6e0296c43336 /llvm/lib/Transforms/Utils/SimplifyCFG.cpp | |
parent | 6df7bdd8109313b08c6eecbe26d31cafc06e80dc (diff) | |
download | bcm5719-llvm-466f54ffcf43c1a9ccc2cca0785abf99f468ad6e.tar.gz bcm5719-llvm-466f54ffcf43c1a9ccc2cca0785abf99f468ad6e.zip |
simplify a bunch of code.
llvm-svn: 121685
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 19 |
1 files changed, 4 insertions, 15 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index 7c80a3dd7a4..1acf8fe05d0 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -2334,22 +2334,11 @@ bool SimplifyCFGOpt::run(BasicBlock *BB) { if (BI && BI->isConditional()) { // Get the other block. BasicBlock *OtherBB = BI->getSuccessor(BI->getSuccessor(0) == BB); - pred_iterator PI = pred_begin(OtherBB); - ++PI; - - if (PI != pred_end(OtherBB)) { - BasicBlock* OnlySucc = NULL; - for (succ_iterator SI = succ_begin(BB), SE = succ_end(BB); - SI != SE; ++SI) { - if (!OnlySucc) - OnlySucc = *SI; - else if (*SI != OnlySucc) { - OnlySucc = 0; // There are multiple distinct successors! - break; - } - } - if (OnlySucc == OtherBB) { + if (OtherBB->getSinglePredecessor() == 0) { + TerminatorInst *BBTerm = BB->getTerminator(); + if (BBTerm->getNumSuccessors() == 1 && + BBTerm->getSuccessor(0) == OtherBB) { // If BB's only successor is the other successor of the predecessor, // i.e. a triangle, see if we can hoist any code from this block up // to the "if" block. |