[PATCH] D50841: [TableGen] TypeSetByHwMode::operator== optimization

Simon Pilgrim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 16 09:17:30 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL339890: [TableGen] TypeSetByHwMode::operator== optimization (authored by RKSimon, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D50841?vs=161024&id=161041#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50841

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


Index: llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp
===================================================================
--- llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp
+++ llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp
@@ -198,16 +198,18 @@
 }
 
 bool TypeSetByHwMode::operator==(const TypeSetByHwMode &VTS) const {
-  bool HaveDefault = hasDefault();
-  if (HaveDefault != VTS.hasDefault())
+  // The isSimple call is much quicker than hasDefault - check this first.
+  bool IsSimple = isSimple();
+  bool VTSIsSimple = VTS.isSimple();
+  if (IsSimple && VTSIsSimple)
+    return *begin() == *VTS.begin();
+
+  // Speedup: We have a default if the set is simple.
+  bool HaveDefault = IsSimple || hasDefault();
+  bool VTSHaveDefault = VTSIsSimple || VTS.hasDefault();
+  if (HaveDefault != VTSHaveDefault)
     return false;
 
-  if (isSimple()) {
-    if (VTS.isSimple())
-      return *begin() == *VTS.begin();
-    return false;
-  }
-
   SmallDenseSet<unsigned, 4> Modes;
   for (auto &I : *this)
     Modes.insert(I.first);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50841.161041.patch
Type: text/x-patch
Size: 1042 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180816/e505ab8b/attachment.bin>


More information about the llvm-commits mailing list