Skip to content

Commit 9c33a2e

Browse files
committed
[MLIR][Presburger] Fold loop into assert
This way it doesn't trigger -Wunused-variable when assertions are disabled.
1 parent 850f713 commit 9c33a2e

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

mlir/lib/Analysis/Presburger/Barvinok.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,10 @@ GeneratingFunction mlir::presburger::detail::unimodularConeGeneratingFunction(
172172
Point mlir::presburger::detail::getNonOrthogonalVector(
173173
ArrayRef<Point> vectors) {
174174
unsigned dim = vectors[0].size();
175-
for (const Point &vector : vectors)
176-
assert(vector.size() == dim && "all vectors need to be the same size!");
175+
assert(
176+
llvm::all_of(vectors,
177+
[&](const Point &vector) { return vector.size() == dim; }) &&
178+
"all vectors need to be the same size!");
177179

178180
SmallVector<Fraction> newPoint = {Fraction(1, 1)};
179181
Fraction maxDisallowedValue = -Fraction(1, 0),
@@ -216,11 +218,12 @@ QuasiPolynomial mlir::presburger::detail::getCoefficientInRationalFunction(
216218
"division by empty denominator in rational function!");
217219

218220
unsigned numParam = num[0].getNumInputs();
219-
for (const QuasiPolynomial &qp : num)
220-
// We use the `isEqual` method of PresburgerSpace, which QuasiPolynomial
221-
// inherits from.
222-
assert(num[0].isEqual(qp) &&
223-
"the quasipolynomials should all belong to the same space!");
221+
// We use the `isEqual` method of PresburgerSpace, which QuasiPolynomial
222+
// inherits from.
223+
assert(
224+
llvm::all_of(
225+
num, [&](const QuasiPolynomial &qp) { return num[0].isEqual(qp); }) &&
226+
"the quasipolynomials should all belong to the same space!");
224227

225228
std::vector<QuasiPolynomial> coefficients;
226229
coefficients.reserve(power + 1);
@@ -241,4 +244,4 @@ QuasiPolynomial mlir::presburger::detail::getCoefficientInRationalFunction(
241244
coefficients[i] = coefficients[i] / den[0];
242245
}
243246
return coefficients[power].simplify();
244-
}
247+
}

0 commit comments

Comments
 (0)