diff --git a/mlir/include/mlir/Analysis/Presburger/IntegerRelation.h b/mlir/include/mlir/Analysis/Presburger/IntegerRelation.h --- a/mlir/include/mlir/Analysis/Presburger/IntegerRelation.h +++ b/mlir/include/mlir/Analysis/Presburger/IntegerRelation.h @@ -128,11 +128,6 @@ /// If there are locals, they will be merged. IntegerRelation intersect(IntegerRelation other) const; - /// Return the intersection of the two relations by directly adding the - /// current relation's constraint to the other relation. This specialized - /// version does not perform additional checks or modifications. - IntegerRelation intersectAddConstraint(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/include/mlir/Analysis/Presburger/PresburgerRelation.h b/mlir/include/mlir/Analysis/Presburger/PresburgerRelation.h --- a/mlir/include/mlir/Analysis/Presburger/PresburgerRelation.h +++ b/mlir/include/mlir/Analysis/Presburger/PresburgerRelation.h @@ -110,6 +110,9 @@ /// false otherwise. bool isIntegerEmpty() const; + /// Return true if there is no disjunct, false otherwise. + bool isPlainEmpty() const; + /// Return true if the set is known to be the universe set, false otherwise. bool isUniverse() const; diff --git a/mlir/lib/Analysis/Presburger/IntegerRelation.cpp b/mlir/lib/Analysis/Presburger/IntegerRelation.cpp --- a/mlir/lib/Analysis/Presburger/IntegerRelation.cpp +++ b/mlir/lib/Analysis/Presburger/IntegerRelation.cpp @@ -75,13 +75,6 @@ return result; } -IntegerRelation -IntegerRelation::intersectAddConstraint(IntegerRelation other) const { - IntegerRelation result = *this; - result.append(other); - return result; -} - bool IntegerRelation::isEqual(const IntegerRelation &other) const { assert(space.isCompatible(other.getSpace()) && "Spaces must be compatible."); return PresburgerRelation(*this).isEqual(PresburgerRelation(other)); diff --git a/mlir/lib/Analysis/Presburger/PresburgerRelation.cpp b/mlir/lib/Analysis/Presburger/PresburgerRelation.cpp --- a/mlir/lib/Analysis/Presburger/PresburgerRelation.cpp +++ b/mlir/lib/Analysis/Presburger/PresburgerRelation.cpp @@ -97,27 +97,14 @@ PresburgerRelation::intersect(const PresburgerRelation &set) const { assert(space.isCompatible(set.getSpace()) && "Spaces should match"); - if ((getNumDisjuncts() == 0 || set.isUniverse()) && - space.isEqual(set.getSpace())) + // When there exists a set that is an empty set or a universe set, just + // directly returns another set + if (isPlainEmpty() || set.isUniverse()) return *this; - if ((set.getNumDisjuncts() == 0 || isUniverse()) && - space.isEqual(set.getSpace())) + if (set.isPlainEmpty() || isUniverse()) return set; - // Special case, where both relation are convex, without any divs and such - // that either one of it contains a single constraint. Simply add constraint - // to the other relation. - if (isConvexNoLocals() && set.isConvexNoLocals() && - space.isEqual(set.getSpace()) && - (getDisjunct(0).getNumConstraints() == 1 || - set.getDisjunct(0).getNumConstraints() == 1)) { - PresburgerRelation result(getSpace()); - result.unionInPlace(getDisjunct(0)); - result.getDisjunct(0).intersectAddConstraint(set.getDisjunct(0)); - return result; - } - PresburgerRelation result(getSpace()); for (const IntegerRelation &csA : disjuncts) { for (const IntegerRelation &csB : set.disjuncts) { @@ -492,6 +479,9 @@ return false; } +/// Return true if there is no disjunct, false otherwise. +bool PresburgerRelation::isPlainEmpty() const { return getNumDisjuncts() == 0; } + /// Return true if all the sets in the union are known to be integer empty, /// false otherwise. bool PresburgerRelation::isIntegerEmpty() const {