[llvm-commits] [llvm] r121685 - /llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
Chris Lattner
sabre at nondot.org
Sun Dec 12 21:20:28 PST 2010
Author: lattner
Date: Sun Dec 12 23:20:28 2010
New Revision: 121685
URL: http://llvm.org/viewvc/llvm-project?rev=121685&view=rev
Log:
simplify a bunch of code.
Modified:
llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=121685&r1=121684&r2=121685&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Sun Dec 12 23:20:28 2010
@@ -2334,22 +2334,11 @@
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.
More information about the llvm-commits
mailing list