Skip to content

Commit 2690d4d

Browse files
committed
[MLIR] Support symbols in emptiness checks for FlatAffineConstraints
Reviewed By: ftynse Differential Revision: https://reviews.llvm.org/D100114
1 parent e10493e commit 2690d4d

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

mlir/lib/Analysis/AffineStructures.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,14 +1151,14 @@ Matrix FlatAffineConstraints::getBoundedDirections() const {
11511151

11521152
bool eqInvolvesSuffixDims(const FlatAffineConstraints &fac, unsigned eqIndex,
11531153
unsigned numDims) {
1154-
for (unsigned e = fac.getNumDimIds(), j = e - numDims; j < e; ++j)
1154+
for (unsigned e = fac.getNumIds(), j = e - numDims; j < e; ++j)
11551155
if (fac.atEq(eqIndex, j) != 0)
11561156
return true;
11571157
return false;
11581158
}
11591159
bool ineqInvolvesSuffixDims(const FlatAffineConstraints &fac,
11601160
unsigned ineqIndex, unsigned numDims) {
1161-
for (unsigned e = fac.getNumDimIds(), j = e - numDims; j < e; ++j)
1161+
for (unsigned e = fac.getNumIds(), j = e - numDims; j < e; ++j)
11621162
if (fac.atIneq(ineqIndex, j) != 0)
11631163
return true;
11641164
return false;

mlir/lib/Analysis/LinearTransform.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ LinearTransform::preMultiplyColumn(ArrayRef<int64_t> colVec) const {
137137

138138
FlatAffineConstraints
139139
LinearTransform::applyTo(const FlatAffineConstraints &fac) const {
140-
FlatAffineConstraints result(fac.getNumDimIds());
140+
FlatAffineConstraints result(fac.getNumIds());
141141

142142
for (unsigned i = 0, e = fac.getNumEqualities(); i < e; ++i) {
143143
ArrayRef<int64_t> eq = fac.getEquality(i);

mlir/unittests/Analysis/AffineStructuresTest.cpp

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,11 @@ static void checkSample(bool hasSample, const FlatAffineConstraints &fac,
5151
/// Construct a FlatAffineConstraints from a set of inequality and
5252
/// equality constraints.
5353
static FlatAffineConstraints
54-
makeFACFromConstraints(unsigned dims, ArrayRef<SmallVector<int64_t, 4>> ineqs,
55-
ArrayRef<SmallVector<int64_t, 4>> eqs) {
56-
FlatAffineConstraints fac(ineqs.size(), eqs.size(), dims + 1, dims);
54+
makeFACFromConstraints(unsigned ids, ArrayRef<SmallVector<int64_t, 4>> ineqs,
55+
ArrayRef<SmallVector<int64_t, 4>> eqs,
56+
unsigned syms = 0) {
57+
FlatAffineConstraints fac(ineqs.size(), eqs.size(), ids + 1, ids - syms,
58+
syms);
5759
for (const auto &eq : eqs)
5860
fac.addEquality(eq);
5961
for (const auto &ineq : ineqs)
@@ -419,6 +421,17 @@ TEST(FlatAffineConstraintsTest, IsIntegerEmptyTest) {
419421
},
420422
{{2, -3, 0, 0, 0}, {1, -1, 6, 0, -1}, {1, 1, 0, -6, -2}})
421423
.isIntegerEmpty());
424+
425+
// Set with symbols.
426+
FlatAffineConstraints fac6 = makeFACFromConstraints(2,
427+
{
428+
{1, 1, 0},
429+
},
430+
{
431+
{1, -1, 0},
432+
},
433+
1);
434+
EXPECT_FALSE(fac6.isIntegerEmpty());
422435
}
423436

424437
TEST(FlatAffineConstraintsTest, removeRedundantConstraintsTest) {

0 commit comments

Comments
 (0)