[Mlir-commits] [mlir] fef4708 - [mlir][affine] addLowerOrUpperBound: Disallow pos among boundOperands

Matthias Springer llvmlistbot at llvm.org
Mon Aug 2 19:27:57 PDT 2021


Author: Matthias Springer
Date: 2021-08-03T11:18:47+09:00
New Revision: fef4708472b2924ee09f2b332d94fe3a99bd5717

URL: https://github.com/llvm/llvm-project/commit/fef4708472b2924ee09f2b332d94fe3a99bd5717
DIFF: https://github.com/llvm/llvm-project/commit/fef4708472b2924ee09f2b332d94fe3a99bd5717.diff

LOG: [mlir][affine] addLowerOrUpperBound: Disallow pos among boundOperands

Bounds such as `dim_{pos} <= c_1 * dim_x + ...` where `x == pos` are invalid. `addLowerOrUpperBound` previously added an incorrect inequality to the set. Such cases are now explicitly rejected.

Differential Revision: https://reviews.llvm.org/D107220

Added: 
    

Modified: 
    mlir/lib/Analysis/AffineStructures.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Analysis/AffineStructures.cpp b/mlir/lib/Analysis/AffineStructures.cpp
index a198d1a208b7..598bf30d5cd8 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<int64_t, 4> ineq(getNumCols(), 0);
     ineq[pos] = lower ? 1 : -1;
     // Dims and symbols.


        


More information about the Mlir-commits mailing list