[llvm] r340020 - [TableGen] TypeSetByHwMode::insert - cache the default MVT. NFCI.

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 17 06:03:17 PDT 2018


Author: rksimon
Date: Fri Aug 17 06:03:17 2018
New Revision: 340020

URL: http://llvm.org/viewvc/llvm-project?rev=340020&view=rev
Log:
[TableGen] TypeSetByHwMode::insert - cache the default MVT. NFCI.

Avoids repeated count()/find() calls that we've already have the default values for.

Modified:
    llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp

Modified: llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp?rev=340020&r1=340019&r2=340020&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp (original)
+++ llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp Fri Aug 17 06:03:17 2018
@@ -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;
 }
 




More information about the llvm-commits mailing list