[Mlir-commits] [mlir] 730acdc - [MLIR][Presburger] fix double increment in coalesce
Arjun P
llvmlistbot at llvm.org
Sat Feb 26 02:37:23 PST 2022
Author: Michel Weber
Date: 2022-02-26T10:37:19Z
New Revision: 730acdc4454ca581211f447f07579cdaf79e2558
URL: https://github.com/llvm/llvm-project/commit/730acdc4454ca581211f447f07579cdaf79e2558
DIFF: https://github.com/llvm/llvm-project/commit/730acdc4454ca581211f447f07579cdaf79e2558.diff
LOG: [MLIR][Presburger] fix double increment in coalesce
In the main-loop of the current coalesce implementation `i` was incremented
twice for some cases. This patch fixes this bug and adds a regression
testcase.
Reviewed By: arjunp
Differential Revision: https://reviews.llvm.org/D120613
Added:
Modified:
mlir/lib/Analysis/Presburger/PresburgerSet.cpp
mlir/unittests/Analysis/Presburger/PresburgerSetTest.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Analysis/Presburger/PresburgerSet.cpp b/mlir/lib/Analysis/Presburger/PresburgerSet.cpp
index b67dc4af4760d..662f2b54dd985 100644
--- a/mlir/lib/Analysis/Presburger/PresburgerSet.cpp
+++ b/mlir/lib/Analysis/Presburger/PresburgerSet.cpp
@@ -521,7 +521,7 @@ PresburgerSet PresburgerSet::coalesce() const {
// When coalescing is successful, the contained IntegerPolyhedron is swapped
// with the last element of `polyhedrons` and subsequently erased and
// similarly for simplices.
- for (unsigned i = 0; i < polyhedrons.size(); ++i) {
+ for (unsigned i = 0; i < polyhedrons.size();) {
// TODO: This does some comparisons two times (index 0 with 1 and index 1
// with 0).
diff --git a/mlir/unittests/Analysis/Presburger/PresburgerSetTest.cpp b/mlir/unittests/Analysis/Presburger/PresburgerSetTest.cpp
index 698db2c17a1a2..05a1c0a1129be 100644
--- a/mlir/unittests/Analysis/Presburger/PresburgerSetTest.cpp
+++ b/mlir/unittests/Analysis/Presburger/PresburgerSetTest.cpp
@@ -619,6 +619,17 @@ TEST(SetTest, coalesceThreeContained) {
expectCoalesce(1, set);
}
+TEST(SetTest, coalesceDoubleIncrement) {
+ PresburgerSet set = parsePresburgerSetFromPolyStrings(
+ 1, {
+ "(x) : (x == 0)",
+ "(x) : (x - 2 == 0)",
+ "(x) : (x + 2 == 0)",
+ "(x) : (x - 2 >= 0, -x + 3 >= 0)",
+ });
+ expectCoalesce(3, set);
+}
+
static void
expectComputedVolumeIsValidOverapprox(const PresburgerSet &set,
Optional<uint64_t> trueVolume,
More information about the Mlir-commits
mailing list