Skip to content

Commit 6c6a2d3

Browse files
committed
[MLIR][Presburger] Minor bug-fix in PresburgerRelation::intersectRange from 3dd9931
Fix a typo (incorrectly calling getNumDomainVars instead of getNumRangeVars) in intersectRange from 3dd9931. Reviewed By: Groverkss Differential Revision: https://reviews.llvm.org/D159413
1 parent b50c87d commit 6c6a2d3

File tree

2 files changed

+29
-20
lines changed

2 files changed

+29
-20
lines changed

mlir/lib/Analysis/Presburger/PresburgerRelation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ PresburgerRelation::intersectDomain(const PresburgerSet &set) const {
159159
"Domain of `this` must be compatible with range of `set`");
160160

161161
PresburgerRelation other = set;
162-
other.insertVarInPlace(VarKind::Domain, 0, getNumDomainVars());
162+
other.insertVarInPlace(VarKind::Domain, 0, getNumRangeVars());
163163
other.inverse();
164164
return intersect(other);
165165
}

mlir/unittests/Analysis/Presburger/PresburgerRelationTest.cpp

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,16 @@ parsePresburgerRelationFromPresburgerSet(ArrayRef<StringRef> strs,
3333
}
3434

3535
TEST(PresburgerRelationTest, intersectDomainAndRange) {
36-
PresburgerRelation rel = parsePresburgerRelationFromPresburgerSet(
37-
{// (x, y) -> (x + N, y - N)
38-
"(x, y, a, b)[N] : (x - a + N == 0, y - b - N == 0)",
39-
// (x, y) -> (x + y, x - y)
40-
"(x, y, a, b)[N] : (a - x - y == 0, b - x + y == 0)",
41-
// (x, y) -> (x - y, y - x)}
42-
"(x, y, a, b)[N] : (a - x + y == 0, b - y + x == 0)"},
43-
2);
44-
4536
{
37+
PresburgerRelation rel = parsePresburgerRelationFromPresburgerSet(
38+
{// (x, y) -> (x + N, y - N)
39+
"(x, y, a, b)[N] : (x - a + N == 0, y - b - N == 0)",
40+
// (x, y) -> (x + y, x - y)
41+
"(x, y, a, b)[N] : (a - x - y == 0, b - x + y == 0)",
42+
// (x, y) -> (x - y, y - x)}
43+
"(x, y, a, b)[N] : (a - x + y == 0, b - y + x == 0)"},
44+
2);
45+
4646
PresburgerSet set =
4747
parsePresburgerSet({// (2x, x)
4848
"(a, b)[N] : (a - 2 * b == 0)",
@@ -71,6 +71,15 @@ TEST(PresburgerRelationTest, intersectDomainAndRange) {
7171
}
7272

7373
{
74+
PresburgerRelation rel = parsePresburgerRelationFromPresburgerSet(
75+
{// (x)[N] -> (x + N, x - N)
76+
"(x, a, b)[N] : (a - x - N == 0, b - x + N == 0)",
77+
// (x)[N] -> (x, -x)
78+
"(x, a, b)[N] : (a - x == 0, b + x == 0)",
79+
// (x)[N] -> (N - x, 2 * x)}
80+
"(x, a, b)[N] : (a - N + x == 0, b - 2 * x == 0)"},
81+
1);
82+
7483
PresburgerSet set =
7584
parsePresburgerSet({// (2x, x)
7685
"(a, b)[N] : (a - 2 * b == 0)",
@@ -80,19 +89,19 @@ TEST(PresburgerRelationTest, intersectDomainAndRange) {
8089
"(a, b)[N] : (a - N == 0, b - N == 0)"});
8190

8291
PresburgerRelation expectedRel = parsePresburgerRelationFromPresburgerSet(
83-
{"(x, y, a, b)[N] : (x - a + N == 0, y - b - N == 0, a - 2 * b == 0)",
84-
"(x, y, a, b)[N] : (x - a + N == 0, y - b - N == 0, a + b == 0)",
85-
"(x, y, a, b)[N] : (x - a + N == 0, y - b - N == 0, a - N == 0, b - N "
92+
{"(x, a, b)[N] : (a - x - N == 0, b - x + N == 0, a - 2 * b == 0)",
93+
"(x, a, b)[N] : (a - x - N == 0, b - x + N == 0, a + b == 0)",
94+
"(x, a, b)[N] : (a - x - N == 0, b - x + N == 0, a - N == 0, b - N "
8695
"== 0)",
87-
"(x, y, a, b)[N] : (a - x - y == 0, b - x + y == 0, a - 2 * b == 0)",
88-
"(x, y, a, b)[N] : (a - x - y == 0, b - x + y == 0, a + b == 0)",
89-
"(x, y, a, b)[N] : (a - x - y == 0, b - x + y == 0, a - N == 0, b - N "
96+
"(x, a, b)[N] : (a - x == 0, b + x == 0, a - 2 * b == 0)",
97+
"(x, a, b)[N] : (a - x == 0, b + x == 0, a + b == 0)",
98+
"(x, a, b)[N] : (a - x == 0, b + x == 0, a - N == 0, b - N "
9099
"== 0)",
91-
"(x, y, a, b)[N] : (a - x + y == 0, b - y + x == 0, a - 2 * b == 0)",
92-
"(x, y, a, b)[N] : (a - x + y == 0, b - y + x == 0, a + b == 0)",
93-
"(x, y, a, b)[N] : (a - x + y == 0, b - y + x == 0, a - N == 0, b - N "
100+
"(x, a, b)[N] : (a - N + x == 0, b - 2 * x == 0, a - 2 * b == 0)",
101+
"(x, a, b)[N] : (a - N + x == 0, b - 2 * x == 0, a + b == 0)",
102+
"(x, a, b)[N] : (a - N + x == 0, b - 2 * x == 0, a - N == 0, b - N "
94103
"== 0)"},
95-
2);
104+
1);
96105

97106
PresburgerRelation computedRel = rel.intersectRange(set);
98107
EXPECT_TRUE(computedRel.isEqual(expectedRel));

0 commit comments

Comments
 (0)