[Mlir-commits] [mlir] 6c6a2d3 - [MLIR][Presburger] Minor bug-fix in PresburgerRelation::intersectRange from 3dd9931

llvmlistbot at llvm.org llvmlistbot at llvm.org
Mon Sep 4 23:34:27 PDT 2023


Author: iambrj
Date: 2023-09-05T11:51:19+05:30
New Revision: 6c6a2d3445671ada6a58b9ab5ce4a1e11e3dd610

URL: https://github.com/llvm/llvm-project/commit/6c6a2d3445671ada6a58b9ab5ce4a1e11e3dd610
DIFF: https://github.com/llvm/llvm-project/commit/6c6a2d3445671ada6a58b9ab5ce4a1e11e3dd610.diff

LOG: [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

Added: 
    

Modified: 
    mlir/lib/Analysis/Presburger/PresburgerRelation.cpp
    mlir/unittests/Analysis/Presburger/PresburgerRelationTest.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Analysis/Presburger/PresburgerRelation.cpp b/mlir/lib/Analysis/Presburger/PresburgerRelation.cpp
index 634047d43464eea..09e7563d58b4898 100644
--- a/mlir/lib/Analysis/Presburger/PresburgerRelation.cpp
+++ b/mlir/lib/Analysis/Presburger/PresburgerRelation.cpp
@@ -159,7 +159,7 @@ PresburgerRelation::intersectDomain(const PresburgerSet &set) const {
          "Domain of `this` must be compatible with range of `set`");
 
   PresburgerRelation other = set;
-  other.insertVarInPlace(VarKind::Domain, 0, getNumDomainVars());
+  other.insertVarInPlace(VarKind::Domain, 0, getNumRangeVars());
   other.inverse();
   return intersect(other);
 }

diff  --git a/mlir/unittests/Analysis/Presburger/PresburgerRelationTest.cpp b/mlir/unittests/Analysis/Presburger/PresburgerRelationTest.cpp
index 20bdb6e7c0c508b..c882a516bc29dfe 100644
--- a/mlir/unittests/Analysis/Presburger/PresburgerRelationTest.cpp
+++ b/mlir/unittests/Analysis/Presburger/PresburgerRelationTest.cpp
@@ -33,16 +33,16 @@ parsePresburgerRelationFromPresburgerSet(ArrayRef<StringRef> strs,
 }
 
 TEST(PresburgerRelationTest, intersectDomainAndRange) {
-  PresburgerRelation rel = parsePresburgerRelationFromPresburgerSet(
-      {// (x, y) -> (x + N, y - N)
-       "(x, y, a, b)[N] : (x - a + N == 0, y - b - N == 0)",
-       // (x, y) -> (x + y, x - y)
-       "(x, y, a, b)[N] : (a - x - y == 0, b - x + y == 0)",
-       // (x, y) -> (x - y, y - x)}
-       "(x, y, a, b)[N] : (a - x + y == 0, b - y + x == 0)"},
-      2);
-
   {
+    PresburgerRelation rel = parsePresburgerRelationFromPresburgerSet(
+        {// (x, y) -> (x + N, y - N)
+         "(x, y, a, b)[N] : (x - a + N == 0, y - b - N == 0)",
+         // (x, y) -> (x + y, x - y)
+         "(x, y, a, b)[N] : (a - x - y == 0, b - x + y == 0)",
+         // (x, y) -> (x - y, y - x)}
+         "(x, y, a, b)[N] : (a - x + y == 0, b - y + x == 0)"},
+        2);
+
     PresburgerSet set =
         parsePresburgerSet({// (2x, x)
                             "(a, b)[N] : (a - 2 * b == 0)",
@@ -71,6 +71,15 @@ TEST(PresburgerRelationTest, intersectDomainAndRange) {
   }
 
   {
+    PresburgerRelation rel = parsePresburgerRelationFromPresburgerSet(
+        {// (x)[N] -> (x + N, x - N)
+         "(x, a, b)[N] : (a - x - N == 0, b - x + N == 0)",
+         // (x)[N] -> (x, -x)
+         "(x, a, b)[N] : (a - x == 0, b + x == 0)",
+         // (x)[N] -> (N - x, 2 * x)}
+         "(x, a, b)[N] : (a - N + x == 0, b - 2 * x == 0)"},
+        1);
+
     PresburgerSet set =
         parsePresburgerSet({// (2x, x)
                             "(a, b)[N] : (a - 2 * b == 0)",
@@ -80,19 +89,19 @@ TEST(PresburgerRelationTest, intersectDomainAndRange) {
                             "(a, b)[N] : (a - N == 0, b - N == 0)"});
 
     PresburgerRelation expectedRel = parsePresburgerRelationFromPresburgerSet(
-        {"(x, y, a, b)[N] : (x - a + N == 0, y - b - N == 0, a - 2 * b == 0)",
-         "(x, y, a, b)[N] : (x - a + N == 0, y - b - N == 0, a + b == 0)",
-         "(x, y, a, b)[N] : (x - a + N == 0, y - b - N == 0, a - N == 0, b - N "
+        {"(x, a, b)[N] : (a - x - N == 0, b - x + N == 0, a - 2 * b == 0)",
+         "(x, a, b)[N] : (a - x - N == 0, b - x + N == 0, a + b == 0)",
+         "(x, a, b)[N] : (a - x - N == 0, b - x + N == 0, a - N == 0, b - N "
          "== 0)",
-         "(x, y, a, b)[N] : (a - x - y == 0, b - x + y == 0, a - 2 * b == 0)",
-         "(x, y, a, b)[N] : (a - x - y == 0, b - x + y == 0, a + b == 0)",
-         "(x, y, a, b)[N] : (a - x - y == 0, b - x + y == 0, a - N == 0, b - N "
+         "(x, a, b)[N] : (a - x == 0, b + x == 0, a - 2 * b == 0)",
+         "(x, a, b)[N] : (a - x == 0, b + x == 0, a + b == 0)",
+         "(x, a, b)[N] : (a - x == 0, b + x == 0, a - N == 0, b - N "
          "== 0)",
-         "(x, y, a, b)[N] : (a - x + y == 0, b - y + x == 0, a - 2 * b == 0)",
-         "(x, y, a, b)[N] : (a - x + y == 0, b - y + x == 0, a + b == 0)",
-         "(x, y, a, b)[N] : (a - x + y == 0, b - y + x == 0, a - N == 0, b - N "
+         "(x, a, b)[N] : (a - N + x == 0, b - 2 * x == 0, a - 2 * b == 0)",
+         "(x, a, b)[N] : (a - N + x == 0, b - 2 * x == 0, a + b == 0)",
+         "(x, a, b)[N] : (a - N + x == 0, b - 2 * x == 0, a - N == 0, b - N "
          "== 0)"},
-        2);
+        1);
 
     PresburgerRelation computedRel = rel.intersectRange(set);
     EXPECT_TRUE(computedRel.isEqual(expectedRel));


        


More information about the Mlir-commits mailing list