[PATCH] D100695: [TableGen] Remove predicate filtering from GenerateVariants.
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 16 22:41:30 PDT 2021
craig.topper updated this revision to Diff 338276.
craig.topper added a comment.
Add the HwModeFeatures comparison I accidentally removed.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D100695/new/
https://reviews.llvm.org/D100695
Files:
llvm/utils/TableGen/CodeGenDAGPatterns.cpp
Index: llvm/utils/TableGen/CodeGenDAGPatterns.cpp
===================================================================
--- llvm/utils/TableGen/CodeGenDAGPatterns.cpp
+++ llvm/utils/TableGen/CodeGenDAGPatterns.cpp
@@ -12,7 +12,6 @@
//===----------------------------------------------------------------------===//
#include "CodeGenDAGPatterns.h"
-#include "llvm/ADT/BitVector.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/MapVector.h"
#include "llvm/ADT/STLExtras.h"
@@ -4646,17 +4645,7 @@
// intentionally do not reconsider these. Any variants of added patterns have
// already been added.
//
- const unsigned NumOriginalPatterns = PatternsToMatch.size();
- BitVector MatchedPatterns(NumOriginalPatterns);
- std::vector<BitVector> MatchedPredicates(NumOriginalPatterns,
- BitVector(NumOriginalPatterns));
-
- typedef std::pair<MultipleUseVarSet, std::vector<TreePatternNodePtr>>
- DepsAndVariants;
- std::map<unsigned, DepsAndVariants> PatternsWithVariants;
-
- // Collect patterns with more than one variant.
- for (unsigned i = 0; i != NumOriginalPatterns; ++i) {
+ for (unsigned i = 0, e = PatternsToMatch.size(); i != e; ++i) {
MultipleUseVarSet DepVars;
std::vector<TreePatternNodePtr> Variants;
FindDepVars(PatternsToMatch[i].getSrcPattern(), DepVars);
@@ -4673,41 +4662,8 @@
LLVM_DEBUG(errs() << "FOUND VARIANTS OF: ";
PatternsToMatch[i].getSrcPattern()->dump(); errs() << "\n");
- PatternsWithVariants[i] = std::make_pair(DepVars, Variants);
-
- // Cache matching predicates.
- if (MatchedPatterns[i])
- continue;
-
- ListInit *Predicates = PatternsToMatch[i].getPredicates();
- const std::string &HwModeFeatures = PatternsToMatch[i].getHwModeFeatures();
-
- BitVector &Matches = MatchedPredicates[i];
- MatchedPatterns.set(i);
- Matches.set(i);
-
- // Don't test patterns that have already been cached - it won't match.
- for (unsigned p = 0; p != NumOriginalPatterns; ++p)
- if (!MatchedPatterns[p])
- Matches[p] = (Predicates == PatternsToMatch[p].getPredicates()) &&
- (HwModeFeatures == PatternsToMatch[p].getHwModeFeatures());
-
- // Copy this to all the matching patterns.
- for (int p = Matches.find_first(); p != -1; p = Matches.find_next(p))
- if (p != (int)i) {
- MatchedPatterns.set(p);
- MatchedPredicates[p] = Matches;
- }
- }
-
- for (const auto &it : PatternsWithVariants) {
- unsigned i = it.first;
- const MultipleUseVarSet &DepVars = it.second.first;
- const std::vector<TreePatternNodePtr> &Variants = it.second.second;
-
for (unsigned v = 0, e = Variants.size(); v != e; ++v) {
TreePatternNodePtr Variant = Variants[v];
- BitVector &Matches = MatchedPredicates[i];
LLVM_DEBUG(errs() << " VAR#" << v << ": "; Variant->dump();
errs() << "\n");
@@ -4716,7 +4672,10 @@
bool AlreadyExists = false;
for (unsigned p = 0, e = PatternsToMatch.size(); p != e; ++p) {
// Skip if the top level predicates do not match.
- if (!Matches[p])
+ if ((i != p) && (PatternsToMatch[i].getPredicates() !=
+ PatternsToMatch[p].getPredicates() ||
+ PatternsToMatch[i].getHwModeFeatures() !=
+ PatternsToMatch[p].getHwModeFeatures()))
continue;
// Check to see if this variant already exists.
if (Variant->isIsomorphicTo(PatternsToMatch[p].getSrcPattern(),
@@ -4737,11 +4696,6 @@
PatternsToMatch[i].getAddedComplexity(), Record::getNewUID(),
PatternsToMatch[i].getForceMode(),
PatternsToMatch[i].getHwModeFeatures());
- MatchedPredicates.push_back(Matches);
-
- // Add a new match the same as this pattern.
- for (auto &P : MatchedPredicates)
- P.push_back(P[i]);
}
LLVM_DEBUG(errs() << "\n");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100695.338276.patch
Type: text/x-patch
Size: 3979 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210417/727d013e/attachment.bin>
More information about the llvm-commits
mailing list