[PATCH] D100889: Better fix for incomplete DefaultPred

Krzysztof Parzyszek via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 20 13:59:24 PDT 2021


kparzysz created this revision.
kparzysz requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100889

Files:
  llvm/utils/TableGen/CodeGenDAGPatterns.cpp


Index: llvm/utils/TableGen/CodeGenDAGPatterns.cpp
===================================================================
--- llvm/utils/TableGen/CodeGenDAGPatterns.cpp
+++ llvm/utils/TableGen/CodeGenDAGPatterns.cpp
@@ -4310,7 +4310,8 @@
   std::vector<PatternToMatch> Copy;
   PatternsToMatch.swap(Copy);
 
-  auto AppendPattern = [this, &ModeChecks](PatternToMatch &P, unsigned Mode) {
+  auto AppendPattern = [this](PatternToMatch &P, unsigned Mode,
+                              const std::vector<Predicate> &Check) {
     TreePatternNodePtr NewSrc = P.getSrcPattern()->clone();
     TreePatternNodePtr NewDst = P.getDstPattern()->clone();
     if (!NewSrc->setDefaultMode(Mode) || !NewDst->setDefaultMode(Mode)) {
@@ -4318,8 +4319,7 @@
     }
 
     std::vector<Predicate> Preds = P.getPredicates();
-    const std::vector<Predicate> &MC = ModeChecks[Mode];
-    llvm::append_range(Preds, MC);
+    llvm::append_range(Preds, Check);
     PatternsToMatch.emplace_back(P.getSrcRecord(), std::move(Preds),
                                  std::move(NewSrc), std::move(NewDst),
                                  P.getDstRegs(),
@@ -4355,31 +4355,31 @@
     // duplicated patterns with different predicate checks, construct the
     // default check as a negation of all predicates that are actually present
     // in the source/destination patterns.
-    std::vector<Predicate> DefaultPred;
+    std::vector<Predicate> DefaultCheck;
 
     for (unsigned M : Modes) {
       if (M == DefaultMode)
         continue;
-      if (ModeChecks.find(M) != ModeChecks.end())
-        continue;
 
-      // Fill the map entry for this mode.
       const HwMode &HM = CGH.getMode(M);
-      ModeChecks[M].emplace_back(Predicate(HM.Features, true));
+      if (ModeChecks.find(M) == ModeChecks.end()) {
+        // Fill the map entry for this mode.
+        ModeChecks[M].emplace_back(Predicate(HM.Features, true));
+      }
 
       // Add negations of the HM's predicates to the default predicate.
-      DefaultPred.emplace_back(Predicate(HM.Features, false));
+      DefaultCheck.emplace_back(Predicate(HM.Features, false));
     }
 
     for (unsigned M : Modes) {
       if (M == DefaultMode)
         continue;
-      AppendPattern(P, M);
+      AppendPattern(P, M, ModeChecks[M]);
     }
 
     bool HasDefault = Modes.count(DefaultMode);
     if (HasDefault)
-      AppendPattern(P, DefaultMode);
+      AppendPattern(P, DefaultMode, DefaultCheck);
   }
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100889.338989.patch
Type: text/x-patch
Size: 2456 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210420/99d471c7/attachment.bin>


More information about the llvm-commits mailing list