[Mlir-commits] [mlir] d81fa76 - [MLIR][Presburger] MultiAffineFunction:eliminateRedundantLocalId: fix bug where local offset was not considered
Arjun P
llvmlistbot at llvm.org
Thu Mar 31 07:11:58 PDT 2022
Author: Arjun P
Date: 2022-03-31T15:11:55+01:00
New Revision: d81fa76f3a6b698d9d76e610eb0a8c0f7ea82eaf
URL: https://github.com/llvm/llvm-project/commit/d81fa76f3a6b698d9d76e610eb0a8c0f7ea82eaf
DIFF: https://github.com/llvm/llvm-project/commit/d81fa76f3a6b698d9d76e610eb0a8c0f7ea82eaf.diff
LOG: [MLIR][Presburger] MultiAffineFunction:eliminateRedundantLocalId: fix bug where local offset was not considered
Previously, when updating the outputs matrix, the local offset was not being considered.
Reviewed By: Groverkss
Differential Revision: https://reviews.llvm.org/D122812
Added:
Modified:
mlir/lib/Analysis/Presburger/PWMAFunction.cpp
mlir/unittests/Analysis/Presburger/PWMAFunctionTest.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Analysis/Presburger/PWMAFunction.cpp b/mlir/lib/Analysis/Presburger/PWMAFunction.cpp
index 42b25111d766b..d00bc2d7f580b 100644
--- a/mlir/lib/Analysis/Presburger/PWMAFunction.cpp
+++ b/mlir/lib/Analysis/Presburger/PWMAFunction.cpp
@@ -110,7 +110,8 @@ void MultiAffineFunction::removeIdRange(IdKind kind, unsigned idStart,
void MultiAffineFunction::eliminateRedundantLocalId(unsigned posA,
unsigned posB) {
- output.addToColumn(posB, posA, /*scale=*/1);
+ unsigned localOffset = getIdKindOffset(IdKind::Local);
+ output.addToColumn(localOffset + posB, localOffset + posA, /*scale=*/1);
IntegerPolyhedron::eliminateRedundantLocalId(posA, posB);
}
diff --git a/mlir/unittests/Analysis/Presburger/PWMAFunctionTest.cpp b/mlir/unittests/Analysis/Presburger/PWMAFunctionTest.cpp
index 79139de6fd011..27d02524ec15b 100644
--- a/mlir/unittests/Analysis/Presburger/PWMAFunctionTest.cpp
+++ b/mlir/unittests/Analysis/Presburger/PWMAFunctionTest.cpp
@@ -157,19 +157,35 @@ TEST(PWMAFunction, valueAt) {
}
TEST(PWMAFunction, removeIdRangeRegressionTest) {
- PWMAFunction pwafA = parsePWMAF(
+ PWMAFunction pwmafA = parsePWMAF(
/*numInputs=*/2, /*numOutputs=*/1,
{
{"(x, y) : (x == 0, y == 0, x - 2*(x floordiv 2) == 0, y - 2*(y "
"floordiv 2) == 0)",
{{0, 0, 0, 0, 0}}} // (0, 0)
});
- PWMAFunction pwafB = parsePWMAF(
+ PWMAFunction pwmafB = parsePWMAF(
/*numInputs=*/2, /*numOutputs=*/1,
{
{"(x, y) : (x - 11*y == 0, 11*x - y == 0, x - 2*(x floordiv 2) == 0, "
"y - 2*(y floordiv 2) == 0)",
{{0, 0, 0, 0, 0}}} // (0, 0)
});
- EXPECT_TRUE(pwafA.isEqual(pwafB));
+ EXPECT_TRUE(pwmafA.isEqual(pwmafB));
+}
+
+TEST(PWMAFunction, eliminateRedundantLocalIdRegressionTest) {
+ PWMAFunction pwmafA = parsePWMAF(
+ /*numInputs=*/2, /*numOutputs=*/1,
+ {
+ {"(x, y) : (x - 2*(x floordiv 2) == 0, x - 2*y == 0)",
+ {{0, 1, 0, 0}}} // (0, 0)
+ });
+ PWMAFunction pwmafB = parsePWMAF(
+ /*numInputs=*/2, /*numOutputs=*/1,
+ {
+ {"(x, y) : (x - 2*(x floordiv 2) == 0, x - 2*y == 0)",
+ {{1, -1, 0, 0}}} // (0, 0)
+ });
+ EXPECT_TRUE(pwmafA.isEqual(pwmafB));
}
More information about the Mlir-commits
mailing list