File tree Expand file tree Collapse file tree 4 files changed +31
-9
lines changed
include/mlir/Analysis/Presburger Expand file tree Collapse file tree 4 files changed +31
-9
lines changed Original file line number Diff line number Diff line change @@ -115,6 +115,16 @@ class IntegerPolyhedron {
115
115
// / intersection with no simplification of any sort attempted.
116
116
void append (const IntegerPolyhedron &other);
117
117
118
+ // / Return whether `this` and `other` are equal. This is integer-exact
119
+ // / and somewhat expensive, since it uses the integer emptiness check
120
+ // / (see IntegerPolyhedron::findIntegerSample()).
121
+ bool isEqual (const IntegerPolyhedron &other) const ;
122
+
123
+ // / Return whether this is a subset of the given IntegerPolyhedron. This is
124
+ // / integer-exact and somewhat expensive, since it uses the integer emptiness
125
+ // / check (see IntegerPolyhedron::findIntegerSample()).
126
+ bool isSubsetOf (const IntegerPolyhedron &other) const ;
127
+
118
128
// / Returns the value at the specified equality row and column.
119
129
inline int64_t atEq (unsigned i, unsigned j) const { return equalities (i, j); }
120
130
inline int64_t &atEq (unsigned i, unsigned j) { return equalities (i, j); }
Original file line number Diff line number Diff line change @@ -77,6 +77,9 @@ class PresburgerSet {
77
77
// / divisions.
78
78
PresburgerSet subtract (const PresburgerSet &set) const ;
79
79
80
+ // / Return true if this set is a subset of the given set, and false otherwise.
81
+ bool isSubsetOf (const PresburgerSet &set) const ;
82
+
80
83
// / Return true if this set is equal to the given set, and false otherwise.
81
84
// / All local variables in both sets must correspond to floor divisions.
82
85
bool isEqual (const PresburgerSet &set) const ;
Original file line number Diff line number Diff line change 12
12
13
13
#include " mlir/Analysis/Presburger/IntegerPolyhedron.h"
14
14
#include " mlir/Analysis/Presburger/LinearTransform.h"
15
+ #include " mlir/Analysis/Presburger/PresburgerSet.h"
15
16
#include " mlir/Analysis/Presburger/Simplex.h"
16
17
#include " mlir/Analysis/Presburger/Utils.h"
17
18
#include " llvm/ADT/DenseMap.h"
@@ -63,6 +64,14 @@ void IntegerPolyhedron::append(const IntegerPolyhedron &other) {
63
64
}
64
65
}
65
66
67
+ bool IntegerPolyhedron::isEqual (const IntegerPolyhedron &other) const {
68
+ return PresburgerSet (*this ).isEqual (PresburgerSet (other));
69
+ }
70
+
71
+ bool IntegerPolyhedron::isSubsetOf (const IntegerPolyhedron &other) const {
72
+ return PresburgerSet (*this ).isSubsetOf (PresburgerSet (other));
73
+ }
74
+
66
75
Optional<SmallVector<Fraction, 8 >>
67
76
IntegerPolyhedron::getRationalLexMin () const {
68
77
assert (numSymbols == 0 && " Symbols are not supported!" );
Original file line number Diff line number Diff line change @@ -352,17 +352,17 @@ PresburgerSet PresburgerSet::subtract(const PresburgerSet &set) const {
352
352
return result;
353
353
}
354
354
355
- // / Two sets S and T are equal iff S contains T and T contains S.
356
- // / By "S contains T", we mean that S is a superset of or equal to T.
357
- // /
358
- // / S contains T iff T \ S is empty, since if T \ S contains a
359
- // / point then this is a point that is contained in T but not S.
360
- // /
361
- // / Therefore, S is equal to T iff S \ T and T \ S are both empty.
355
+ // / T is a subset of S iff T \ S is empty, since if T \ S contains a
356
+ // / point then this is a point that is contained in T but not S, and
357
+ // / if T contains a point that is not in S, this also lies in T \ S.
358
+ bool PresburgerSet::isSubsetOf (const PresburgerSet &set) const {
359
+ return this ->subtract (set).isIntegerEmpty ();
360
+ }
361
+
362
+ // / Two sets are equal iff they are subsets of each other.
362
363
bool PresburgerSet::isEqual (const PresburgerSet &set) const {
363
364
assertDimensionsCompatible (set, *this );
364
- return this ->subtract (set).isIntegerEmpty () &&
365
- set.subtract (*this ).isIntegerEmpty ();
365
+ return this ->isSubsetOf (set) && set.isSubsetOf (*this );
366
366
}
367
367
368
368
// / Return true if all the sets in the union are known to be integer empty,
You can’t perform that action at this time.
0 commit comments