diff --git a/mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp b/mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp --- a/mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp +++ b/mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp @@ -648,7 +648,7 @@ LogicalResult FlatAffineValueConstraints::addAffineParallelOpDomain( AffineParallelOp parallelOp) { size_t ivPos = 0; - for (auto iv : parallelOp.getIVs()) { + for (Value iv : parallelOp.getIVs()) { unsigned pos; if (!findVar(iv, &pos)) { assert(false && "variable expected for the IV value"); @@ -668,6 +668,7 @@ else if (failed(addBound(BoundType::UB, pos, upperBound, parallelOp.getUpperBoundsOperands()))) return failure(); + ++ivPos; } return success(); } diff --git a/mlir/test/Transforms/memref-dependence-check.mlir b/mlir/test/Transforms/memref-dependence-check.mlir --- a/mlir/test/Transforms/memref-dependence-check.mlir +++ b/mlir/test/Transforms/memref-dependence-check.mlir @@ -1102,3 +1102,31 @@ } return } + +// ----- + +// CHECK-LABEL: func @affine_parallel_dep_check +func.func @affine_parallel_dep_check() { + %memref_23 = memref.alloc() : memref<1x130xf32> + %memref_25 = memref.alloc() : memref<1x130x130xf32> + %cst = arith.constant 0.0 : f32 + affine.parallel (%arg4, %arg5) = (0, 0) to (1, 130) { + affine.store %cst, %memref_25[%arg4, %arg5, 129] : memref<1x130x130xf32> + // expected-remark@above {{dependence from 0 to 0 at depth 1 = false}} + // expected-remark@above {{dependence from 0 to 0 at depth 2 = false}} + // expected-remark@above {{dependence from 0 to 0 at depth 3 = false}} + // expected-remark@above {{dependence from 0 to 1 at depth 1 = true}} + } + %memref_27 = memref.alloc() : memref<1x128x128xf32> + affine.parallel (%arg4) = (0) to (130) { + affine.parallel (%arg5, %arg6) = (0, 0) to (1, 130) { + affine.load %memref_25[0, %arg4 + %arg5, %arg6] : memref<1x130x130xf32> + // expected-remark@above {{dependence from 1 to 1 at depth 1 = false}} + // expected-remark@above {{dependence from 1 to 1 at depth 2 = false}} + // expected-remark@above {{dependence from 1 to 1 at depth 3 = false}} + // expected-remark@above {{dependence from 1 to 1 at depth 4 = false}} + // expected-remark@above {{dependence from 1 to 0 at depth 1 = false}} + } + } + return +}