aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils/SimplifyCFG.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-12-13 05:20:28 +0000
committerChris Lattner <sabre@nondot.org>2010-12-13 05:20:28 +0000
commiteff7edf12628fd83426ce18cf315b12ca6c76923 (patch)
treee864bfc71c2f34110f802a1c9216f30eb91857e7 /lib/Transforms/Utils/SimplifyCFG.cpp
parentef5002ba85121178766edd096818a781fdc2dece (diff)
simplify a bunch of code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121685 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r--lib/Transforms/Utils/SimplifyCFG.cpp19
1 files changed, 4 insertions, 15 deletions
diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp b/lib/Transforms/Utils/SimplifyCFG.cpp
index 7c80a3dd7a..1acf8fe05d 100644
--- a/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/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.