[llvm] r254192 - [TableGen] Sort pattern predicates before concatenating into a string so that different orders of the same set will produce the same string. This can reduce the number of unique predicates in the isel tables. NFC
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 26 21:44:04 PST 2015
Author: ctopper
Date: Thu Nov 26 23:44:04 2015
New Revision: 254192
URL: http://llvm.org/viewvc/llvm-project?rev=254192&view=rev
Log:
[TableGen] Sort pattern predicates before concatenating into a string so that different orders of the same set will produce the same string. This can reduce the number of unique predicates in the isel tables. NFC
Modified:
llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp
Modified: llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp?rev=254192&r1=254191&r2=254192&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp (original)
+++ llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp Thu Nov 26 23:44:04 2015
@@ -857,7 +857,7 @@ getPatternComplexity(const CodeGenDAGPat
/// pattern's predicates concatenated with "&&" operators.
///
std::string PatternToMatch::getPredicateCheck() const {
- std::string PredicateCheck;
+ SmallVector<Record *, 4> PredicateRecs;
for (Init *I : Predicates->getValues()) {
if (DefInit *Pred = dyn_cast<DefInit>(I)) {
Record *Def = Pred->getDef();
@@ -867,11 +867,18 @@ std::string PatternToMatch::getPredicate
#endif
llvm_unreachable("Unknown predicate type!");
}
- if (!PredicateCheck.empty())
- PredicateCheck += " && ";
- PredicateCheck += "(" + Def->getValueAsString("CondString") + ")";
+ PredicateRecs.push_back(Def);
}
}
+ // Sort so that different orders get canonicalized to the same string.
+ std::sort(PredicateRecs.begin(), PredicateRecs.end(), LessRecord());
+
+ std::string PredicateCheck;
+ for (Record *Pred : PredicateRecs) {
+ if (!PredicateCheck.empty())
+ PredicateCheck += " && ";
+ PredicateCheck += "(" + Pred->getValueAsString("CondString") + ")";
+ }
return PredicateCheck;
}
More information about the llvm-commits
mailing list