1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 19:12:56 +02:00

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
This commit is contained in:
Chris Lattner 2005-01-01 16:02:12 +00:00
parent fcc2ae9a85
commit 5fff877f74

View File

@ -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.