[PATCH] D92161: [GlobalISel] Remove duplicates from possible mappings

Gabriel Hjort Ã…kerlund via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 26 02:27:07 PST 2020


ehjogab updated this revision to Diff 307801.
ehjogab added a comment.

Reduce number of necessary checks.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92161/new/

https://reviews.llvm.org/D92161

Files:
  llvm/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h
  llvm/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp


Index: llvm/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp
===================================================================
--- llvm/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp
+++ llvm/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp
@@ -421,8 +421,13 @@
 
   // Then the alternative mapping, if any.
   InstructionMappings AltMappings = getInstrAlternativeMappings(MI);
-  for (const InstructionMapping *AltMapping : AltMappings)
+  for (const InstructionMapping *AltMapping : AltMappings) {
+    // Check that we don't already have such a mapping.
+    if (AltMapping->isCompatibleMapping(Mapping)) {
+      continue;
+    }
     PossibleMappings.push_back(AltMapping);
+  }
 #ifndef NDEBUG
   for (const InstructionMapping *Mapping : PossibleMappings)
     assert(Mapping->verify(MI) && "Mapping is invalid");
Index: llvm/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h
===================================================================
--- llvm/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h
+++ llvm/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h
@@ -220,6 +220,12 @@
           NumOperands(NumOperands) {
     }
 
+    /// Check if this mapping has the same \p OperandsMapping as another \p
+    /// Mapping.
+    bool isCompatibleMapping(const InstructionMapping &Mapping) const {
+      return this->OperandsMapping == Mapping.OperandsMapping;
+    }
+
     /// Default constructor.
     /// Use this constructor to express that the mapping is invalid.
     InstructionMapping() = default;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D92161.307801.patch
Type: text/x-patch
Size: 1506 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201126/1731e5a6/attachment.bin>


More information about the llvm-commits mailing list