Skip to content

[MLIR][Presburger] Fix bug in Identifier::isEqual assert #76380

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions mlir/lib/Analysis/Presburger/PresburgerSpace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ using namespace presburger;
bool Identifier::isEqual(const Identifier &other) const {
if (value == nullptr || other.value == nullptr)
return false;
assert(value == other.value && idType == other.idType &&
"Values of Identifiers are equal but their types do not match.");
assert(value != other.value ||
(value == other.value && idType == other.idType &&
"Values of Identifiers are equal but their types do not match."));
return value == other.value;
}

Expand Down
14 changes: 14 additions & 0 deletions mlir/unittests/Analysis/Presburger/PresburgerSpaceTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,20 @@ TEST(PresburgerSpaceTest, removeVarRangeIdentifier) {
EXPECT_EQ(space.getId(VarKind::Range, 1), Identifier(&identifiers[5]));
}

TEST(PresburgerSpaceTest, IdentifierIsEqual) {
PresburgerSpace space = PresburgerSpace::getRelationSpace(1, 2, 0, 0);
space.resetIds();

int identifiers[2] = {0, 1};
space.getId(VarKind::Domain, 0) = Identifier(&identifiers[0]);
space.getId(VarKind::Range, 0) = Identifier(&identifiers[0]);
space.getId(VarKind::Range, 1) = Identifier(&identifiers[1]);

EXPECT_EQ(space.getId(VarKind::Domain, 0), space.getId(VarKind::Range, 0));
EXPECT_FALSE(
space.getId(VarKind::Range, 0).isEqual(space.getId(VarKind::Range, 1)));
}

TEST(PresburgerSpaceTest, convertVarKind) {
PresburgerSpace space = PresburgerSpace::getRelationSpace(2, 2, 0, 0);
space.resetIds();
Expand Down