[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:15:59 PST 2020
ehjogab created this revision.
ehjogab added reviewers: dsanders, arsenm, qcolombet, ab, bjope, rovka.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.
ehjogab requested review of this revision.
Herald added a subscriber: wdng.
Some targets will in getInstrAlternativeMappings() will return a list
that contains the mapping returned by getInstrMapping(), thereby causing
duplicates. This patch removes such duplicates, which reduces the amount
of work that needs to be done when selecting register banks.
Repository:
rG LLVM Github Monorepo
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,19 @@
// Then the alternative mapping, if any.
InstructionMappings AltMappings = getInstrAlternativeMappings(MI);
- for (const InstructionMapping *AltMapping : AltMappings)
- PossibleMappings.push_back(AltMapping);
+ for (const InstructionMapping *AltMapping : AltMappings) {
+ // Check that we don't already have such a mapping.
+ bool AlreadyExists = false;
+ for (const InstructionMapping *Mapping : PossibleMappings) {
+ if (AltMapping->isCompatibleMapping(*Mapping)) {
+ AlreadyExists = true;
+ break;
+ }
+ }
+ if (!AlreadyExists) {
+ 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.307798.patch
Type: text/x-patch
Size: 1728 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201126/c907a77e/attachment.bin>
More information about the llvm-commits
mailing list