diff --git a/mlir/include/mlir/Analysis/Presburger/IntegerPolyhedron.h b/mlir/include/mlir/Analysis/Presburger/IntegerPolyhedron.h index ad32d7a7aba9a6..933f20e441225b 100644 --- a/mlir/include/mlir/Analysis/Presburger/IntegerPolyhedron.h +++ b/mlir/include/mlir/Analysis/Presburger/IntegerPolyhedron.h @@ -189,8 +189,8 @@ class IntegerPolyhedron { /// Return the index at which the specified kind of id starts. unsigned getIdKindOffset(IdKind kind) const; - /// Assert that `value` is at most the number of ids of the specified kind. - void assertAtMostNumIdKind(unsigned value, IdKind kind) const; + /// Get the number of ids of the specified kind. + unsigned getNumIdKind(IdKind kind) const; /// Removes identifiers in the column range [idStart, idLimit), and copies any /// remaining valid data into place, updates member variables, and resizes diff --git a/mlir/lib/Analysis/Presburger/IntegerPolyhedron.cpp b/mlir/lib/Analysis/Presburger/IntegerPolyhedron.cpp index 5fc6533a98c14f..3c4f512bf4fbe6 100644 --- a/mlir/lib/Analysis/Presburger/IntegerPolyhedron.cpp +++ b/mlir/lib/Analysis/Presburger/IntegerPolyhedron.cpp @@ -65,7 +65,7 @@ unsigned IntegerPolyhedron::insertLocalId(unsigned pos, unsigned num) { } unsigned IntegerPolyhedron::insertId(IdKind kind, unsigned pos, unsigned num) { - assertAtMostNumIdKind(pos, kind); + assert(pos <= getNumIdKind(kind)); unsigned absolutePos = getIdKindOffset(kind) + pos; if (kind == IdKind::Dimension) @@ -120,7 +120,7 @@ void IntegerPolyhedron::removeId(unsigned pos) { removeIdRange(pos, pos + 1); } void IntegerPolyhedron::removeIdRange(IdKind kind, unsigned idStart, unsigned idLimit) { - assertAtMostNumIdKind(idLimit, kind); + assert(idLimit <= getNumIdKind(kind)); removeIdRange(getIdKindOffset(kind) + idStart, getIdKindOffset(kind) + idLimit); } @@ -203,15 +203,14 @@ unsigned IntegerPolyhedron::getIdKindOffset(IdKind kind) const { llvm_unreachable("IdKind expected to be Dimension, Symbol or Local!"); } -void IntegerPolyhedron::assertAtMostNumIdKind(unsigned val, IdKind kind) const { +unsigned IntegerPolyhedron::getNumIdKind(IdKind kind) const { if (kind == IdKind::Dimension) - assert(val <= getNumDimIds()); - else if (kind == IdKind::Symbol) - assert(val <= getNumSymbolIds()); - else if (kind == IdKind::Local) - assert(val <= getNumLocalIds()); - else - llvm_unreachable("IdKind expected to be Dimension, Symbol or Local!"); + return getNumDimIds(); + if (kind == IdKind::Symbol) + return getNumSymbolIds(); + if (kind == IdKind::Local) + return getNumLocalIds(); + llvm_unreachable("IdKind expected to be Dimension, Symbol or Local!"); } void IntegerPolyhedron::clearConstraints() {