@@ -315,6 +315,7 @@ TEST(OperandStorageTest, PopulateDefaultAttrs) {
315315TEST (OperationEquivalenceTest, HashWorksWithFlags) {
316316 MLIRContext context;
317317 context.getOrLoadDialect <test::TestDialect>();
318+ OpBuilder b (&context);
318319
319320 auto *op1 = createOp (&context);
320321 // `op1` has an unknown loc.
@@ -325,12 +326,36 @@ TEST(OperationEquivalenceTest, HashWorksWithFlags) {
325326 op, OperationEquivalence::ignoreHashValue,
326327 OperationEquivalence::ignoreHashValue, flags);
327328 };
329+ // Check ignore location.
328330 EXPECT_EQ (getHash (op1, OperationEquivalence::IgnoreLocations),
329331 getHash (op2, OperationEquivalence::IgnoreLocations));
330332 EXPECT_NE (getHash (op1, OperationEquivalence::None),
331333 getHash (op2, OperationEquivalence::None));
334+ op1->setLoc (NameLoc::get (StringAttr::get (&context, " foo" )));
335+ // Check ignore discardable dictionary attributes.
336+ SmallVector<NamedAttribute> newAttrs = {
337+ b.getNamedAttr (" foo" , b.getStringAttr (" f" ))};
338+ op1->setAttrs (newAttrs);
339+ EXPECT_EQ (getHash (op1, OperationEquivalence::IgnoreDiscardableAttrs),
340+ getHash (op2, OperationEquivalence::IgnoreDiscardableAttrs));
341+ EXPECT_NE (getHash (op1, OperationEquivalence::None),
342+ getHash (op2, OperationEquivalence::None));
332343 op1->destroy ();
333344 op2->destroy ();
345+
346+ // Check ignore properties.
347+ auto req1 = b.getI32IntegerAttr (10 );
348+ Operation *opWithProperty1 = b.create <test::OpAttrMatch1>(
349+ b.getUnknownLoc (), req1, nullptr , nullptr , req1);
350+ auto req2 = b.getI32IntegerAttr (60 );
351+ Operation *opWithProperty2 = b.create <test::OpAttrMatch1>(
352+ b.getUnknownLoc (), req2, nullptr , nullptr , req2);
353+ EXPECT_NE (getHash (op1, OperationEquivalence::None),
354+ getHash (op2, OperationEquivalence::None));
355+ EXPECT_EQ (getHash (opWithProperty1, OperationEquivalence::IgnoreProperties),
356+ getHash (opWithProperty2, OperationEquivalence::IgnoreProperties));
357+ opWithProperty1->destroy ();
358+ opWithProperty2->destroy ();
334359}
335360
336361} // namespace
0 commit comments