Skip to content

Commit

Permalink
[MLIR] Fix bug in addAffineParallelOpDomain upper bound constraint
Browse files Browse the repository at this point in the history
Fix upper bound constraint addition in addAffineParallelOpDomain; it was
off by one in the case of constants.

Differential Revision: https://reviews.llvm.org/D144836
  • Loading branch information
bondhugula committed Feb 28, 2023
1 parent dbfc037 commit a2802dd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp
Expand Up @@ -664,7 +664,7 @@ LogicalResult FlatAffineValueConstraints::addAffineParallelOpDomain(

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();
Expand Down
20 changes: 18 additions & 2 deletions mlir/test/Transforms/memref-dependence-check.mlir
Expand Up @@ -1105,8 +1105,7 @@ func.func @affine_if_no_dependence() {

// -----

// 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
Expand All @@ -1130,3 +1129,20 @@ func.func @affine_parallel_dep_check() {
}
return
}

// -----

func.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
}

0 comments on commit a2802dd

Please sign in to comment.