[CSE] NFC: Hash the attribute dictionary pointer instead of the list of attributes.
authorRiver Riddle <riverriddle@google.com>
Wed, 4 Dec 2019 20:31:36 +0000 (12:31 -0800)
committerA. Unique TensorFlower <gardener@tensorflow.org>
Wed, 4 Dec 2019 20:32:08 +0000 (12:32 -0800)
PiperOrigin-RevId: 283810829

mlir/include/mlir/IR/Attributes.h
mlir/lib/Transforms/CSE.cpp

index b5b9a0491f4f1ac34f4a57b0cd1fd342c4eede84..ebff99ddcd518e495422c8b8d8299256199f6be3 100644 (file)
@@ -1373,6 +1373,13 @@ public:
       : attrs((attrs && !attrs.empty()) ? attrs : nullptr) {}
   NamedAttributeList(ArrayRef<NamedAttribute> attributes);
 
+  bool operator!=(const NamedAttributeList &other) const {
+    return !(*this == other);
+  }
+  bool operator==(const NamedAttributeList &other) const {
+    return attrs == other.attrs;
+  }
+
   /// Return the underlying dictionary attribute. This may be null, if this list
   /// has no attributes.
   DictionaryAttr getDictionary() const { return attrs; }
index c3d30bf65a1bf0b799bd2b19a126ad3daa46d968..70eb69c2f9cff87ed5c5304126c066fb552cc8ff 100644 (file)
@@ -47,7 +47,7 @@ struct SimpleOperationInfo : public llvm::DenseMapInfo<Operation *> {
     //   - Result Types
     //   - Operands
     return hash_combine(
-        op->getName(), op->getAttrs(),
+        op->getName(), op->getAttrList().getDictionary(),
         hash_combine_range(op->result_type_begin(), op->result_type_end()),
         hash_combine_range(op->operand_begin(), op->operand_end()));
   }
@@ -68,7 +68,7 @@ struct SimpleOperationInfo : public llvm::DenseMapInfo<Operation *> {
         lhs->getNumResults() != rhs->getNumResults())
       return false;
     // Compare attributes.
-    if (lhs->getAttrs() != rhs->getAttrs())
+    if (lhs->getAttrList() != rhs->getAttrList())
       return false;
     // Compare operands.
     if (!std::equal(lhs->operand_begin(), lhs->operand_end(),