[Mlir-commits] [mlir] a2802dd - [MLIR] Fix bug in addAffineParallelOpDomain upper bound constraint

Uday Bondhugula llvmlistbot at llvm.org
Mon Feb 27 21:06:25 PST 2023


Author: Uday Bondhugula
Date: 2023-02-28T10:28:24+05:30
New Revision: a2802dd24f62c14ae00d1691bb19a20d130ec68d

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

LOG: [MLIR] Fix bug in addAffineParallelOpDomain upper bound constraint

Fix upper bound constraint addition in addAffineParallelOpDomain; it was
off by one in the case of constants.

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

Added: 
    

Modified: 
    mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp
    mlir/test/Transforms/memref-dependence-check.mlir

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp b/mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp
index 4a7effa4b89b1..f26a97c9f1f08 100644
--- a/mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp
+++ b/mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp
@@ -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();

diff  --git a/mlir/test/Transforms/memref-dependence-check.mlir b/mlir/test/Transforms/memref-dependence-check.mlir
index 10f5c0c4463b9..3a16a33a1ed11 100644
--- a/mlir/test/Transforms/memref-dependence-check.mlir
+++ b/mlir/test/Transforms/memref-dependence-check.mlir
@@ -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
@@ -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 at above {{dependence from 0 to 0 at depth 1 = false}}
+    // expected-remark at above {{dependence from 0 to 0 at depth 2 = false}}
+    // expected-remark at above {{dependence from 0 to 1 at depth 1 = false}}
+  }
+  affine.load %m[127]: memref<128xf32>
+  // expected-remark at above {{dependence from 1 to 1 at depth 1 = false}}
+  // expected-remark at above {{dependence from 1 to 0 at depth 1 = false}}
+  return
+}


        


More information about the Mlir-commits mailing list