summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Pilgrim <llvm-dev@redking.me.uk>2018-08-17 13:03:17 +0000
committerSimon Pilgrim <llvm-dev@redking.me.uk>2018-08-17 13:03:17 +0000
commit16a2f54eee3bfd7844ac6d1fde1abdd0be4c471f (patch)
treebfcac3f7b2b97d9c8020cc220b25ab2c9f5a93e0
parent0ac44c18b7682c82aa7575b5c14cda0bbee798ad (diff)
downloadbcm5719-llvm-16a2f54eee3bfd7844ac6d1fde1abdd0be4c471f.tar.gz
bcm5719-llvm-16a2f54eee3bfd7844ac6d1fde1abdd0be4c471f.zip
[TableGen] TypeSetByHwMode::insert - cache the default MVT. NFCI.
Avoids repeated count()/find() calls that we've already have the default values for. llvm-svn: 340020
-rw-r--r--llvm/utils/TableGen/CodeGenDAGPatterns.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/llvm/utils/TableGen/CodeGenDAGPatterns.cpp b/llvm/utils/TableGen/CodeGenDAGPatterns.cpp
index 4ef437523d5..c9dc8a96c8c 100644
--- a/llvm/utils/TableGen/CodeGenDAGPatterns.cpp
+++ b/llvm/utils/TableGen/CodeGenDAGPatterns.cpp
@@ -99,22 +99,29 @@ bool TypeSetByHwMode::isPossible() const {
bool TypeSetByHwMode::insert(const ValueTypeByHwMode &VVT) {
bool Changed = false;
+ bool ContainsDefault = false;
+ MVT DT = MVT::Other;
+
SmallDenseSet<unsigned, 4> Modes;
for (const auto &P : VVT) {
unsigned M = P.first;
Modes.insert(M);
// Make sure there exists a set for each specific mode from VVT.
Changed |= getOrCreate(M).insert(P.second).second;
+ // Cache VVT's default mode.
+ if (DefaultMode == M) {
+ ContainsDefault = true;
+ DT = P.second;
+ }
}
// If VVT has a default mode, add the corresponding type to all
// modes in "this" that do not exist in VVT.
- if (Modes.count(DefaultMode)) {
- MVT DT = VVT.getType(DefaultMode);
+ if (ContainsDefault)
for (auto &I : *this)
if (!Modes.count(I.first))
Changed |= I.second.insert(DT).second;
- }
+
return Changed;
}
OpenPOWER on IntegriCloud