diff --git a/mlir/lib/Analysis/AffineStructures.cpp b/mlir/lib/Analysis/AffineStructures.cpp index a198d1a208b72..598bf30d5cd8d 100644 --- a/mlir/lib/Analysis/AffineStructures.cpp +++ b/mlir/lib/Analysis/AffineStructures.cpp @@ -2004,6 +2004,10 @@ FlatAffineConstraints::addLowerOrUpperBound(unsigned pos, AffineMap boundMap, } for (const auto &flatExpr : flatExprs) { + // Invalid bound: pos appears among the operands. + if (llvm::find(positions, pos) != positions.end()) + continue; + SmallVector ineq(getNumCols(), 0); ineq[pos] = lower ? 1 : -1; // Dims and symbols.