aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-09-29 05:43:32 +0000
committerChris Lattner <sabre@nondot.org>2004-09-29 05:43:32 +0000
commit0ed7f42c1b6e6dab8b531d7f2fa45ed2fe310849 (patch)
treed4ae39425617372cec68a99c9d49cd005872aeed /lib
parent4e998b2fea377b8853d2e074b40d33f48163d859 (diff)
downloadexternal_llvm-0ed7f42c1b6e6dab8b531d7f2fa45ed2fe310849.zip
external_llvm-0ed7f42c1b6e6dab8b531d7f2fa45ed2fe310849.tar.gz
external_llvm-0ed7f42c1b6e6dab8b531d7f2fa45ed2fe310849.tar.bz2
Do not insert trivially dead select instructions, which allows us to
potentially fold more in one pass. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16583 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Transforms/Utils/SimplifyCFG.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp b/lib/Transforms/Utils/SimplifyCFG.cpp
index baa737e..77d3fe3 100644
--- a/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -753,10 +753,19 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
FalseSucc->removePredecessor(BI->getParent());
// Insert a new select instruction.
- Value *NewRetVal = new SelectInst(BI->getCondition(), TrueValue,
- FalseValue, "retval", BI);
+ Value *NewRetVal;
+ Value *BrCond = BI->getCondition();
+ if (TrueValue != FalseValue)
+ NewRetVal = new SelectInst(BrCond, TrueValue,
+ FalseValue, "retval", BI);
+ else
+ NewRetVal = TrueValue;
+
new ReturnInst(NewRetVal, BI);
BI->getParent()->getInstList().erase(BI);
+ if (BrCond->use_empty())
+ if (Instruction *BrCondI = dyn_cast<Instruction>(BrCond))
+ BrCondI->getParent()->getInstList().erase(BrCondI);
return true;
}
}