[MLIR][Presburger] make sample test with integer lexmin use containsPointNoLocal
authorArjun P <arjunpitchanathan@gmail.com>
Mon, 8 Aug 2022 13:42:53 +0000 (14:42 +0100)
committerArjun P <arjunpitchanathan@gmail.com>
Mon, 8 Aug 2022 13:46:02 +0000 (14:46 +0100)
IntegerPolyhedron::findIntegerLexmin currently does not return values of
the local ids, so when a test for sampling includes a set with locals, the
result of findIntegerLexmin should be checked using containsPointNoLocal,
not containsPoint.

mlir/include/mlir/Analysis/Presburger/IntegerRelation.h
mlir/unittests/Analysis/Presburger/IntegerPolyhedronTest.cpp

index 333669f69c2e1a00599da5fb93cd86d17d02975a..b6922d9795f4cf6ea43f1dae48cea5a0c01d83ba 100644 (file)
@@ -336,7 +336,7 @@ public:
   /// additional processing using Simplex for unbounded sets.
   ///
   /// Returns an integer sample point if one exists, or an empty Optional
-  /// otherwise.
+  /// otherwise. The returned value also includes values of local ids.
   Optional<SmallVector<int64_t, 8>> findIntegerSample() const;
 
   /// Compute an overapproximation of the number of integer points in the
index d0231a9b5af6cd2dee681f4fa392b28a9f3423dc..2ed4cd62b4a09fb4681e86f61f7ce299126dea94 100644 (file)
@@ -86,7 +86,7 @@ static void checkSample(bool hasSample, const IntegerPolyhedron &poly,
         EXPECT_TRUE(Simplex(poly).isUnbounded());
       }
       if (maybeLexMin.isBounded()) {
-        EXPECT_TRUE(poly.containsPoint(*maybeLexMin));
+        EXPECT_TRUE(poly.containsPointNoLocal(*maybeLexMin));
       }
     }
     break;
@@ -410,6 +410,9 @@ TEST(IntegerPolyhedronTest, FindSampleTest) {
   checkSample(true, parsePoly("(x, y, z) : (2 * x - 1 >= 0, x - y - 1 == 0, "
                               "y - z == 0)"));
 
+  // Test with a local id.
+  checkSample(true, parsePoly("(x) : (x == 5*(x floordiv 2))"));
+
   // Regression tests for the computation of dual coefficients.
   checkSample(false, parsePoly("(x, y, z) : ("
                                "6*x - 4*y + 9*z + 2 >= 0,"