Simplify, now that predsimplify depends on break-crit-edges.

Fix SwitchInst where dest-block is the same as one of the cases.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30700 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Nick Lewycky 2006-10-03 15:19:11 +00:00
parent 5c8c5d9ace
commit a73a654bb4

View File

@ -413,8 +413,6 @@ namespace {
// Used by terminator instructions to proceed from the current basic // Used by terminator instructions to proceed from the current basic
// block to the next. Verifies that "current" dominates "next", // block to the next. Verifies that "current" dominates "next",
// then calls visitBasicBlock. // then calls visitBasicBlock.
void proceedToSuccessor(TerminatorInst *TI, unsigned edge,
PropertySet &CurrentPS, PropertySet &NextPS);
void proceedToSuccessors(PropertySet &CurrentPS, BasicBlock *Current); void proceedToSuccessors(PropertySet &CurrentPS, BasicBlock *Current);
// Visits each instruction in the basic block. // Visits each instruction in the basic block.
@ -616,17 +614,6 @@ void PredicateSimplifier::visitInstruction(Instruction *I,
visit(BO, KnownProperties); visit(BO, KnownProperties);
} }
// The basic block on the target of the specified edge must be known
// to be immediately dominated by the parent of the TerminatorInst.
void PredicateSimplifier::proceedToSuccessor(TerminatorInst *TI,
unsigned edge,
PropertySet &CurrentPS,
PropertySet &NextPS) {
assert(edge < TI->getNumSuccessors() && "Invalid index for edge.");
visitBasicBlock(TI->getSuccessor(edge), NextPS);
}
void PredicateSimplifier::proceedToSuccessors(PropertySet &KP, void PredicateSimplifier::proceedToSuccessors(PropertySet &KP,
BasicBlock *BBCurrent) { BasicBlock *BBCurrent) {
DTNodeType *Current = DT->getNode(BBCurrent); DTNodeType *Current = DT->getNode(BBCurrent);
@ -676,14 +663,14 @@ void PredicateSimplifier::visit(BranchInst *BI, PropertySet &KP) {
if ((*I)->getBlock() == TrueDest) { if ((*I)->getBlock() == TrueDest) {
PropertySet TrueProperties(KP); PropertySet TrueProperties(KP);
TrueProperties.addEqual(ConstantBool::getTrue(), Condition); TrueProperties.addEqual(ConstantBool::getTrue(), Condition);
proceedToSuccessor(BI, 0, KP, TrueProperties); visitBasicBlock(TrueDest, TrueProperties);
continue; continue;
} }
if ((*I)->getBlock() == FalseDest) { if ((*I)->getBlock() == FalseDest) {
PropertySet FalseProperties(KP); PropertySet FalseProperties(KP);
FalseProperties.addEqual(ConstantBool::getFalse(), Condition); FalseProperties.addEqual(ConstantBool::getFalse(), Condition);
proceedToSuccessor(BI, 1, KP, FalseProperties); visitBasicBlock(FalseDest, FalseProperties);
continue; continue;
} }
@ -702,20 +689,15 @@ void PredicateSimplifier::visit(SwitchInst *SI, PropertySet KP) {
for (DTNodeType::iterator I = Node->begin(), E = Node->end(); I != E; ++I) { for (DTNodeType::iterator I = Node->begin(), E = Node->end(); I != E; ++I) {
BasicBlock *BB = (*I)->getBlock(); BasicBlock *BB = (*I)->getBlock();
PropertySet Copy(KP); PropertySet BBProperties(KP);
if (BB == SI->getDefaultDest()) { if (BB == SI->getDefaultDest()) {
PropertySet NewProperties(KP);
for (unsigned i = 1, e = SI->getNumCases(); i < e; ++i) for (unsigned i = 1, e = SI->getNumCases(); i < e; ++i)
NewProperties.addNotEqual(Condition, SI->getCaseValue(i)); if (SI->getSuccessor(i) != BB)
BBProperties.addNotEqual(Condition, SI->getCaseValue(i));
proceedToSuccessor(SI, 0, Copy, NewProperties);
} else if (ConstantInt *CI = SI->findCaseDest(BB)) { } else if (ConstantInt *CI = SI->findCaseDest(BB)) {
PropertySet NewProperties(KP); BBProperties.addEqual(Condition, CI);
NewProperties.addEqual(Condition, CI); }
proceedToSuccessor(SI, SI->findCaseValue(CI), Copy, NewProperties); visitBasicBlock(BB, BBProperties);
} else
visitBasicBlock(BB, Copy);
} }
} }