[Mlir-commits] [mlir] [mlir]: Added properties/attributes ignore flags to OperationEquivalence (PR #141664)

Krzysztof Drewniak llvmlistbot at llvm.org
Thu May 29 11:56:51 PDT 2025


================
@@ -325,10 +326,25 @@ TEST(OperationEquivalenceTest, HashWorksWithFlags) {
         op, OperationEquivalence::ignoreHashValue,
         OperationEquivalence::ignoreHashValue, flags);
   };
+  // Check ignore location.
   EXPECT_EQ(getHash(op1, OperationEquivalence::IgnoreLocations),
             getHash(op2, OperationEquivalence::IgnoreLocations));
   EXPECT_NE(getHash(op1, OperationEquivalence::None),
             getHash(op2, OperationEquivalence::None));
+  op1->setLoc(NameLoc::get(StringAttr::get(&context, "foo")));
+  // Check ignore discardable dictionary attributes.
+  SmallVector<NamedAttribute> newAttrs = {
+      b.getNamedAttr("foo", b.getStringAttr("f"))};
+  op1->setAttrs(newAttrs);
+  EXPECT_EQ(
+      getHash(op1, OperationEquivalence::IgnoreDiscardableDictionaryAttrs),
+      getHash(op2, OperationEquivalence::IgnoreDiscardableDictionaryAttrs));
+  EXPECT_NE(getHash(op1, OperationEquivalence::None),
+            getHash(op2, OperationEquivalence::None));
+  op2->setAttrs(newAttrs);
+  // Check ignore properties.
+  EXPECT_EQ(getHash(op1, OperationEquivalence::IgnoreProperties),
+            getHash(op2, OperationEquivalence::IgnoreProperties));
----------------
krzysz00 wrote:

I think you're missing a test where two operations are NE except when you ignore their properties. You might need an operation with an inherent attribute or property on it (not sure if there's already one in context, I don't know this test)(

https://github.com/llvm/llvm-project/pull/141664


More information about the Mlir-commits mailing list