summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-01-01 16:02:12 +0000
committerChris Lattner <sabre@nondot.org>2005-01-01 16:02:12 +0000
commit3215bb6049b63dee1cfb1246e230a8d0fa3172ff (patch)
treefe972fa26d9b1ab2c0923441b04771846dac243b /llvm/lib/Transforms
parent21adf7d36e0f77ae1f9a1e083985cd591b9d76e1 (diff)
downloadbcm5719-llvm-3215bb6049b63dee1cfb1246e230a8d0fa3172ff.tar.gz
bcm5719-llvm-3215bb6049b63dee1cfb1246e230a8d0fa3172ff.zip
Implement SimplifyCFG/DeadSetCC.ll
SimplifyCFG is one of those passes that we use for final cleanup: it should not rely on other passes to clean up its garbage. This fixes the "why are trivially dead setcc's in the output of gccas" problem. llvm-svn: 19212
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Utils/SimplifyCFG.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index bbeb28d9772..f4d02573cdc 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -521,8 +521,16 @@ static bool FoldValueComparisonIntoPredecessors(TerminatorInst *TI) {
SwitchInst *NewSI = new SwitchInst(CV, PredDefault, PTI);
for (unsigned i = 0, e = PredCases.size(); i != e; ++i)
NewSI->addCase(PredCases[i].first, PredCases[i].second);
+
+ Instruction *DeadCond = 0;
+ if (BranchInst *BI = dyn_cast<BranchInst>(PTI))
+ // If PTI is a branch, remember the condition.
+ DeadCond = dyn_cast<Instruction>(BI->getCondition());
Pred->getInstList().erase(PTI);
+ // If the condition is dead now, remove the instruction tree.
+ if (DeadCond) ErasePossiblyDeadInstructionTree(DeadCond);
+
// Okay, last check. If BB is still a successor of PSI, then we must
// have an infinite loop case. If so, add an infinitely looping block
// to handle the case to preserve the behavior of the code.
OpenPOWER on IntegriCloud