[Mlir-commits] [mlir] b68e78c - [MLIR][Prebsurger] Add IntegerRelation::intersect supporting locals properly
Arjun P
llvmlistbot at llvm.org
Tue Mar 22 06:13:47 PDT 2022
Author: Arjun P
Date: 2022-03-22T13:13:56Z
New Revision: b68e78cea65faef45342a2af420b32877413e9c5
URL: https://github.com/llvm/llvm-project/commit/b68e78cea65faef45342a2af420b32877413e9c5
DIFF: https://github.com/llvm/llvm-project/commit/b68e78cea65faef45342a2af420b32877413e9c5.diff
LOG: [MLIR][Prebsurger] Add IntegerRelation::intersect supporting locals properly
Reviewed By: Groverkss
Differential Revision: https://reviews.llvm.org/D122149
Added:
Modified:
mlir/include/mlir/Analysis/Presburger/IntegerRelation.h
mlir/lib/Analysis/Presburger/IntegerRelation.cpp
mlir/lib/Analysis/Presburger/PresburgerRelation.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir/Analysis/Presburger/IntegerRelation.h b/mlir/include/mlir/Analysis/Presburger/IntegerRelation.h
index f8f06b8ff9ae8..fa149491cd7ad 100644
--- a/mlir/include/mlir/Analysis/Presburger/IntegerRelation.h
+++ b/mlir/include/mlir/Analysis/Presburger/IntegerRelation.h
@@ -95,6 +95,10 @@ class IntegerRelation : public PresburgerLocalSpace {
/// intersection with no simplification of any sort attempted.
void append(const IntegerRelation &other);
+ /// Return the intersection of the two sets.
+ /// If there are locals, they will be merged.
+ IntegerRelation intersect(IntegerRelation other) const;
+
/// Return whether `this` and `other` are equal. This is integer-exact
/// and somewhat expensive, since it uses the integer emptiness check
/// (see IntegerRelation::findIntegerSample()).
diff --git a/mlir/lib/Analysis/Presburger/IntegerRelation.cpp b/mlir/lib/Analysis/Presburger/IntegerRelation.cpp
index 1917d9a480cfb..3f647a033e9b5 100644
--- a/mlir/lib/Analysis/Presburger/IntegerRelation.cpp
+++ b/mlir/lib/Analysis/Presburger/IntegerRelation.cpp
@@ -52,6 +52,13 @@ void IntegerRelation::append(const IntegerRelation &other) {
}
}
+IntegerRelation IntegerRelation::intersect(IntegerRelation other) const {
+ IntegerRelation result = *this;
+ result.mergeLocalIds(other);
+ result.append(other);
+ return result;
+}
+
bool IntegerRelation::isEqual(const IntegerRelation &other) const {
assert(PresburgerLocalSpace::isEqual(other) && "Spaces must be equal.");
return PresburgerRelation(*this).isEqual(PresburgerRelation(other));
diff --git a/mlir/lib/Analysis/Presburger/PresburgerRelation.cpp b/mlir/lib/Analysis/Presburger/PresburgerRelation.cpp
index 6f035aa4e2662..37a3b78adb269 100644
--- a/mlir/lib/Analysis/Presburger/PresburgerRelation.cpp
+++ b/mlir/lib/Analysis/Presburger/PresburgerRelation.cpp
@@ -97,11 +97,9 @@ PresburgerRelation::intersect(const PresburgerRelation &set) const {
getNumSymbolIds());
for (const IntegerRelation &csA : integerRelations) {
for (const IntegerRelation &csB : set.integerRelations) {
- IntegerRelation csACopy = csA, csBCopy = csB;
- csACopy.mergeLocalIds(csBCopy);
- csACopy.append(csBCopy);
- if (!csACopy.isEmpty())
- result.unionInPlace(csACopy);
+ IntegerRelation intersection = csA.intersect(csB);
+ if (!intersection.isEmpty())
+ result.unionInPlace(intersection);
}
}
return result;
More information about the Mlir-commits
mailing list