Ignore redundant constraints

llvm-svn: 42397
This commit is contained in:
Daniel Berlin 2007-09-27 15:42:23 +00:00
parent cc61bf5e0c
commit a447de7065
1 changed files with 20 additions and 2 deletions

View File

@ -134,6 +134,21 @@ namespace {
assert(Offset == 0 || Ty != AddressOf && assert(Offset == 0 || Ty != AddressOf &&
"Offset is illegal on addressof constraints"); "Offset is illegal on addressof constraints");
} }
bool operator==(const Constraint &RHS) const {
return RHS.Type == Type
&& RHS.Dest == Dest
&& RHS.Src == Src
&& RHS.Offset == Offset;
}
bool operator<(const Constraint &RHS) const {
if (RHS.Type != Type)
return RHS.Type < Type;
else if (RHS.Dest != Dest)
return RHS.Dest < Dest;
else if (RHS.Src != Src)
return RHS.Src < Src;
return RHS.Offset < Offset;
}
}; };
// Node class - This class is used to represent a node in the constraint // Node class - This class is used to represent a node in the constraint
@ -1735,6 +1750,7 @@ void Andersens::HUValNum(unsigned NodeIndex) {
/// replaced by their the pointer equivalence class representative. /// replaced by their the pointer equivalence class representative.
void Andersens::RewriteConstraints() { void Andersens::RewriteConstraints() {
std::vector<Constraint> NewConstraints; std::vector<Constraint> NewConstraints;
std::set<Constraint> Seen;
PEClass2Node.clear(); PEClass2Node.clear();
PENLEClass2Node.clear(); PENLEClass2Node.clear();
@ -1771,9 +1787,11 @@ void Andersens::RewriteConstraints() {
C.Src = FindEquivalentNode(RHSNode, RHSLabel); C.Src = FindEquivalentNode(RHSNode, RHSLabel);
C.Dest = FindEquivalentNode(FindNode(LHSNode), LHSLabel); C.Dest = FindEquivalentNode(FindNode(LHSNode), LHSLabel);
if (C.Src == C.Dest && C.Type == Constraint::Copy) if (C.Src == C.Dest && C.Type == Constraint::Copy
|| Seen.count(C) != 0)
continue; continue;
Seen.insert(C);
NewConstraints.push_back(C); NewConstraints.push_back(C);
} }
Constraints.swap(NewConstraints); Constraints.swap(NewConstraints);