@@ -295,6 +295,7 @@ TEST(OperandStorageTest, PopulateDefaultAttrs) {
295295TEST (OperationEquivalenceTest, HashWorksWithFlags) {
296296 MLIRContext context;
297297 context.getOrLoadDialect <test::TestDialect>();
298+ OpBuilder b (&context);
298299
299300 auto *op1 = createOp (&context);
300301 // `op1` has an unknown loc.
@@ -305,12 +306,36 @@ TEST(OperationEquivalenceTest, HashWorksWithFlags) {
305306 op, OperationEquivalence::ignoreHashValue,
306307 OperationEquivalence::ignoreHashValue, flags);
307308 };
309+ // Check ignore location.
308310 EXPECT_EQ (getHash (op1, OperationEquivalence::IgnoreLocations),
309311 getHash (op2, OperationEquivalence::IgnoreLocations));
310312 EXPECT_NE (getHash (op1, OperationEquivalence::None),
311313 getHash (op2, OperationEquivalence::None));
314+ op1->setLoc (NameLoc::get (StringAttr::get (&context, " foo" )));
315+ // Check ignore discardable dictionary attributes.
316+ SmallVector<NamedAttribute> newAttrs = {
317+ b.getNamedAttr (" foo" , b.getStringAttr (" f" ))};
318+ op1->setAttrs (newAttrs);
319+ EXPECT_EQ (getHash (op1, OperationEquivalence::IgnoreDiscardableAttrs),
320+ getHash (op2, OperationEquivalence::IgnoreDiscardableAttrs));
321+ EXPECT_NE (getHash (op1, OperationEquivalence::None),
322+ getHash (op2, OperationEquivalence::None));
312323 op1->destroy ();
313324 op2->destroy ();
325+
326+ // Check ignore properties.
327+ auto req1 = b.getI32IntegerAttr (10 );
328+ Operation *opWithProperty1 = b.create <test::OpAttrMatch1>(
329+ b.getUnknownLoc (), req1, nullptr , nullptr , req1);
330+ auto req2 = b.getI32IntegerAttr (60 );
331+ Operation *opWithProperty2 = b.create <test::OpAttrMatch1>(
332+ b.getUnknownLoc (), req2, nullptr , nullptr , req2);
333+ EXPECT_EQ (getHash (opWithProperty1, OperationEquivalence::IgnoreProperties),
334+ getHash (opWithProperty2, OperationEquivalence::IgnoreProperties));
335+ EXPECT_NE (getHash (opWithProperty1, OperationEquivalence::None),
336+ getHash (opWithProperty2, OperationEquivalence::None));
337+ opWithProperty1->destroy ();
338+ opWithProperty2->destroy ();
314339}
315340
316341} // namespace
0 commit comments