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 @@ -664,7 +664,7 @@ auto upperBound = parallelOp.getUpperBoundMap(ivPos); if (upperBound.isConstant()) - addBound(BoundType::UB, pos, upperBound.getSingleConstantResult()); + addBound(BoundType::UB, pos, upperBound.getSingleConstantResult() - 1); else if (failed(addBound(BoundType::UB, pos, upperBound, parallelOp.getUpperBoundsOperands()))) return failure(); 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 @@ -1105,8 +1105,7 @@ // ----- -// CHECK-LABEL: func @affine_parallel_dep_check -func.func @affine_parallel_dep_check() { +func.func @affine_parallel_dep_check_1() { %memref_23 = memref.alloc() : memref<1x130xf32> %memref_25 = memref.alloc() : memref<1x130x130xf32> %cst = arith.constant 0.0 : f32 @@ -1130,3 +1129,20 @@ } return } + +// ----- + +func @affine_parallel_dep_check_2() { + %m = memref.alloc() : memref<128xf32> + %cst = arith.constant 0.0 : f32 + affine.parallel (%arg4) = (0) to (127) { + affine.store %cst, %m[%arg4] : memref<128xf32> + // 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 1 at depth 1 = false}} + } + affine.load %m[127]: memref<128xf32> + // expected-remark@above {{dependence from 1 to 1 at depth 1 = false}} + // expected-remark@above {{dependence from 1 to 0 at depth 1 = false}} + return +}