[llvm-commits] CVS: llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp
Nick Lewycky
nicholas at mxc.ca
Thu Aug 31 20:26:49 PDT 2006
Changes in directory llvm/lib/Transforms/Scalar:
PredicateSimplifier.cpp updated: 1.3 -> 1.4
---
Log message:
Don't confuse canonicalize and lookup. Fixes predsimplify.reg4.ll. Also
corrects missing optimization opportunity removing cases from a switch.
---
Diffs of the changes: (+20 -21)
PredicateSimplifier.cpp | 41 ++++++++++++++++++++---------------------
1 files changed, 20 insertions(+), 21 deletions(-)
Index: llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp
diff -u llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp:1.3 llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp:1.4
--- llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp:1.3 Wed Aug 30 19:39:16 2006
+++ llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp Thu Aug 31 22:26:35 2006
@@ -576,30 +576,29 @@
void PredicateSimplifier::visit(SwitchInst *SI,
DominatorTree::Node *DTNode, PropertySet KP) {
Value *Condition = SI->getCondition();
+ DEBUG(assert(Condition == KP.canonicalize(Condition) &&
+ "Instruction wasn't already canonicalized?"));
// If there's an NEProperty covering this SwitchInst, we may be able to
// eliminate one of the cases.
- if (Value *C = KP.lookup(Condition)) {
- Condition = C;
- for (PropertySet::ConstPropertyIterator I = KP.Properties.begin(),
- E = KP.Properties.end(); I != E; ++I) {
- if (I->Opcode != PropertySet::NE) continue;
- Value *V1 = KP.lookup(I->V1),
- *V2 = KP.lookup(I->V2);
- if (V1 != C && V2 != C) continue;
-
- // Is one side a number?
- ConstantInt *CI = dyn_cast<ConstantInt>(KP.lookup(I->V1));
- if (!CI) CI = dyn_cast<ConstantInt>(KP.lookup(I->V2));
-
- if (CI) {
- unsigned i = SI->findCaseValue(CI);
- if (i != 0) {
- SI->getSuccessor(i)->removePredecessor(SI->getParent());
- SI->removeCase(i);
- modified = true;
- ++NumSwitchCases;
- }
+ for (PropertySet::ConstPropertyIterator I = KP.Properties.begin(),
+ E = KP.Properties.end(); I != E; ++I) {
+ if (I->Opcode != PropertySet::NE) continue;
+ Value *V1 = KP.canonicalize(I->V1),
+ *V2 = KP.canonicalize(I->V2);
+ if (V1 != Condition && V2 != Condition) continue;
+
+ // Is one side a number?
+ ConstantInt *CI = dyn_cast<ConstantInt>(KP.canonicalize(I->V1));
+ if (!CI) CI = dyn_cast<ConstantInt>(KP.canonicalize(I->V2));
+
+ if (CI) {
+ unsigned i = SI->findCaseValue(CI);
+ if (i != 0) {
+ SI->getSuccessor(i)->removePredecessor(SI->getParent());
+ SI->removeCase(i);
+ modified = true;
+ ++NumSwitchCases;
}
}
}
More information about the llvm-commits
mailing list