From 6f895bec7d63e31ad005b0ae05395eb016e5014f Mon Sep 17 00:00:00 2001 From: River Riddle Date: Wed, 4 Dec 2019 12:31:36 -0800 Subject: [PATCH] [CSE] NFC: Hash the attribute dictionary pointer instead of the list of attributes. PiperOrigin-RevId: 283810829 --- mlir/include/mlir/IR/Attributes.h | 7 +++++++ mlir/lib/Transforms/CSE.cpp | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/mlir/include/mlir/IR/Attributes.h b/mlir/include/mlir/IR/Attributes.h index b5b9a0491f4f..ebff99ddcd51 100644 --- a/mlir/include/mlir/IR/Attributes.h +++ b/mlir/include/mlir/IR/Attributes.h @@ -1373,6 +1373,13 @@ public: : attrs((attrs && !attrs.empty()) ? attrs : nullptr) {} NamedAttributeList(ArrayRef 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; } diff --git a/mlir/lib/Transforms/CSE.cpp b/mlir/lib/Transforms/CSE.cpp index c3d30bf65a1b..70eb69c2f9cf 100644 --- a/mlir/lib/Transforms/CSE.cpp +++ b/mlir/lib/Transforms/CSE.cpp @@ -47,7 +47,7 @@ struct SimpleOperationInfo : public llvm::DenseMapInfo { // - 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 { 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(),