From 79728453b7f6ba166289ec15c902eac8f35e2162 Mon Sep 17 00:00:00 2001 From: Arjun P Date: Wed, 2 Feb 2022 19:02:34 +0530 Subject: [PATCH] [MLIR][Presburger] Simplify checkExplicitRepresentation This also gets rid of a clang-tidy warning. Reviewed By: Groverkss Differential Revision: https://reviews.llvm.org/D118780 --- mlir/lib/Analysis/Presburger/Utils.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/mlir/lib/Analysis/Presburger/Utils.cpp b/mlir/lib/Analysis/Presburger/Utils.cpp index c42e653593bb..a06304b1a266 100644 --- a/mlir/lib/Analysis/Presburger/Utils.cpp +++ b/mlir/lib/Analysis/Presburger/Utils.cpp @@ -184,23 +184,23 @@ static LogicalResult getDivRepr(const IntegerPolyhedron &cst, unsigned pos, // explicit representation has not been found yet, otherwise returns `true`. static bool checkExplicitRepresentation(const IntegerPolyhedron &cst, ArrayRef foundRepr, - SmallVectorImpl ÷nd, + ArrayRef dividend, unsigned pos) { // Exit to avoid circular dependencies between divisions. - unsigned c, f; - for (c = 0, f = cst.getNumIds(); c < f; ++c) { + for (unsigned c = 0, e = cst.getNumIds(); c < e; ++c) { if (c == pos) continue; - if (!foundRepr[c] && dividend[c] != 0) - break; + + if (!foundRepr[c] && dividend[c] != 0) { + // Expression can't be constructed as it depends on a yet unknown + // identifier. + // + // TODO: Visit/compute the identifiers in an order so that this doesn't + // happen. More complex but much more efficient. + return false; + } } - // Expression can't be constructed as it depends on a yet unknown - // identifier. - // TODO: Visit/compute the identifiers in an order so that this doesn't - // happen. More complex but much more efficient. - if (c < f) - return false; return true; }