Changes in directory llvm/lib/Transforms/Scalar:
PredicateSimplifier.cpp updated: 1.2 -> 1.3 --- Log message: Properties where both Values weren't in the union (as being equal to another Value) weren't being found by findProperties. This fixes predsimplify.ll test6, a missed optimization opportunity. --- Diffs of the changes: (+18 -24) PredicateSimplifier.cpp | 42 ++++++++++++++++++------------------------ 1 files changed, 18 insertions(+), 24 deletions(-) Index: llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp diff -u llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp:1.2 llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp:1.3 --- llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp:1.2 Tue Aug 29 21:46:48 2006 +++ llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp Wed Aug 30 19:39:16 2006 @@ -121,21 +121,8 @@ void addNotEqual(Value *V1, Value *V2) { DEBUG(std::cerr << "not equal: " << *V1 << " and " << *V2 << "\n"); - V1 = canonicalize(V1); - V2 = canonicalize(V2); - - // Does the property already exist? - for (PropertyIterator I = Properties.begin(), E = Properties.end(); - I != E; ++I) { - if (I->Opcode != NE) continue; - - I->V1 = canonicalize(I->V1); - I->V2 = canonicalize(I->V2); - if ((I->V1 == V1 && I->V2 == V2) || - (I->V1 == V2 && I->V2 == V1)) { - return; // Found. - } - } + if (findProperty(NE, V1, V2) != Properties.end()) + return; // found. // Add the property. Properties.push_back(Property(NE, V1, V2)); @@ -146,9 +133,8 @@ assert(Opcode != EQ && "Can't findProperty on EQ." "Use the lookup method instead."); - V1 = lookup(V1); - V2 = lookup(V2); - if (!V1 || !V2) return Properties.end(); + V1 = canonicalize(V1); + V2 = canonicalize(V2); // Does the property already exist? for (PropertyIterator I = Properties.begin(), E = Properties.end(); @@ -170,18 +156,16 @@ assert(Opcode != EQ && "Can't findProperty on EQ." "Use the lookup method instead."); - V1 = lookup(V1); - V2 = lookup(V2); - if (!V1 || !V2) return Properties.end(); + V1 = canonicalize(V1); + V2 = canonicalize(V2); // Does the property already exist? for (ConstPropertyIterator I = Properties.begin(), E = Properties.end(); I != E; ++I) { if (I->Opcode != Opcode) continue; - Value *v1 = lookup(I->V1), - *v2 = lookup(I->V2); - if (!v1 || !v2) continue; + Value *v1 = canonicalize(I->V1), + *v2 = canonicalize(I->V2); if ((v1 == V1 && v2 == V2) || (v1 == V2 && v2 == V1)) { return I; // Found. @@ -291,6 +275,14 @@ public: void debug(std::ostream &os) const { + for (EquivalenceClasses<Value*>::iterator I = union_find.begin(), + E = union_find.end(); I != E; ++I) { + if (!I->isLeader()) continue; + for (EquivalenceClasses<Value*>::member_iterator MI = + union_find.member_begin(I); MI != union_find.member_end(); ++MI) + std::cerr << **MI << " "; + std::cerr << "\n--\n"; + } } std::vector<Property> Properties; @@ -571,8 +563,10 @@ PropertySet TrueProperties(KP), FalseProperties(KP); DEBUG(std::cerr << "true set:\n"); TrueProperties.addEqual(ConstantBool::True, Condition); + DEBUG(TrueProperties.debug(std::cerr)); DEBUG(std::cerr << "false set:\n"); FalseProperties.addEqual(ConstantBool::False, Condition); + DEBUG(FalseProperties.debug(std::cerr)); PropertySet KPcopy(KP); proceedToSuccessor(KP, TrueProperties, Node, DT->getNode(TrueDest)); _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits