Skip to content

Commit

Permalink
[MLIR][Presburger] Fold loop into assert
Browse files Browse the repository at this point in the history
This way it doesn't trigger -Wunused-variable when assertions are disabled.
  • Loading branch information
d0k authored and justinfargnoli committed Jan 28, 2024
1 parent dd9932a commit 131e20c
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions mlir/lib/Analysis/Presburger/Barvinok.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,10 @@ GeneratingFunction mlir::presburger::detail::unimodularConeGeneratingFunction(
Point mlir::presburger::detail::getNonOrthogonalVector(
ArrayRef<Point> vectors) {
unsigned dim = vectors[0].size();
for (const Point &vector : vectors)
assert(vector.size() == dim && "all vectors need to be the same size!");
assert(
llvm::all_of(vectors,
[&](const Point &vector) { return vector.size() == dim; }) &&
"all vectors need to be the same size!");

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

unsigned numParam = num[0].getNumInputs();
for (const QuasiPolynomial &qp : num)
// We use the `isEqual` method of PresburgerSpace, which QuasiPolynomial
// inherits from.
assert(num[0].isEqual(qp) &&
"the quasipolynomials should all belong to the same space!");
// We use the `isEqual` method of PresburgerSpace, which QuasiPolynomial
// inherits from.
assert(
llvm::all_of(
num, [&](const QuasiPolynomial &qp) { return num[0].isEqual(qp); }) &&
"the quasipolynomials should all belong to the same space!");

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

0 comments on commit 131e20c

Please sign in to comment.