aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJay Foad <jay.foad@amd.com>2024-02-13 13:44:31 +0000
committerGitHub <noreply@github.com>2024-02-13 13:44:31 +0000
commit880afa1c5d1b099eed5034340a67e56b9dda4c09 (patch)
treeff0c766100b774efb8083a88087054d7470808b2
parenta17a3e9d9a6b4baefd96e19ee5e8ce04cead8ab5 (diff)
downloadllvm-880afa1c5d1b099eed5034340a67e56b9dda4c09.zip
llvm-880afa1c5d1b099eed5034340a67e56b9dda4c09.tar.gz
llvm-880afa1c5d1b099eed5034340a67e56b9dda4c09.tar.bz2
[TableGen] Use vectors instead of sets for testing intersection. NFC. (#81602)
In a few places we test whether sets (i.e. sorted ranges) intersect by computing the set_intersection and then testing whether it is empty. For this purpose it should be more efficient to use a std:vector instead of a std::set to hold the result of the set_intersection, since insertion is simpler.
-rw-r--r--llvm/utils/TableGen/AsmMatcherEmitter.cpp7
-rw-r--r--llvm/utils/TableGen/CodeGenRegisters.cpp11
2 files changed, 8 insertions, 10 deletions
diff --git a/llvm/utils/TableGen/AsmMatcherEmitter.cpp b/llvm/utils/TableGen/AsmMatcherEmitter.cpp
index 9065885..a212265 100644
--- a/llvm/utils/TableGen/AsmMatcherEmitter.cpp
+++ b/llvm/utils/TableGen/AsmMatcherEmitter.cpp
@@ -242,11 +242,10 @@ public:
if (!isRegisterClass() || !RHS.isRegisterClass())
return false;
- RegisterSet Tmp;
- std::insert_iterator<RegisterSet> II(Tmp, Tmp.begin());
+ std::vector<Record *> Tmp;
std::set_intersection(Registers.begin(), Registers.end(),
- RHS.Registers.begin(), RHS.Registers.end(), II,
- LessRecordByID());
+ RHS.Registers.begin(), RHS.Registers.end(),
+ std::back_inserter(Tmp), LessRecordByID());
return !Tmp.empty();
}
diff --git a/llvm/utils/TableGen/CodeGenRegisters.cpp b/llvm/utils/TableGen/CodeGenRegisters.cpp
index 25f3864..5c74a6f 100644
--- a/llvm/utils/TableGen/CodeGenRegisters.cpp
+++ b/llvm/utils/TableGen/CodeGenRegisters.cpp
@@ -2034,12 +2034,11 @@ void CodeGenRegBank::computeRegUnitSets() {
// Compare new sets with all original classes.
for (unsigned SearchIdx = (Idx >= NumRegUnitSubSets) ? 0 : Idx + 1;
SearchIdx != EndIdx; ++SearchIdx) {
- std::set<unsigned> Intersection;
- std::set_intersection(RegUnitSets[Idx].Units.begin(),
- RegUnitSets[Idx].Units.end(),
- RegUnitSets[SearchIdx].Units.begin(),
- RegUnitSets[SearchIdx].Units.end(),
- std::inserter(Intersection, Intersection.begin()));
+ std::vector<unsigned> Intersection;
+ std::set_intersection(
+ RegUnitSets[Idx].Units.begin(), RegUnitSets[Idx].Units.end(),
+ RegUnitSets[SearchIdx].Units.begin(),
+ RegUnitSets[SearchIdx].Units.end(), std::back_inserter(Intersection));
if (Intersection.empty())
continue;