[Mlir-commits] [mlir] [MLIR][Affine] Add missing check in affine data copy nest generation (PR #127809)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Wed Feb 19 07:24:33 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir-affine
Author: Uday Bondhugula (bondhugula)
<details>
<summary>Changes</summary>
Handle case where no lower or upper bound could be found for a
dimension. Invalid IR was being generated silently for a test case.
Fixes: https://github.com/llvm/llvm-project/issues/127808
---
Full diff: https://github.com/llvm/llvm-project/pull/127809.diff
2 Files Affected:
- (modified) mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp (+6-1)
- (modified) mlir/test/Dialect/Affine/affine-data-copy.mlir (+6-5)
``````````diff
diff --git a/mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp b/mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp
index 4e02559a08949..c618671d07f1f 100644
--- a/mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp
+++ b/mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp
@@ -2001,8 +2001,13 @@ static LogicalResult generateCopy(
}
SmallVector<AffineMap, 4> lbMaps(rank), ubMaps(rank);
- for (unsigned i = 0; i < rank; ++i)
+ for (unsigned i = 0; i < rank; ++i) {
region.getLowerAndUpperBound(i, lbMaps[i], ubMaps[i]);
+ if (lbMaps[i].getNumResults() == 0 || ubMaps[i].getNumResults() == 0) {
+ LLVM_DEBUG(llvm::dbgs() << "Missing lower or upper bound for region\n");
+ return failure();
+ }
+ }
const FlatAffineValueConstraints *cst = region.getConstraints();
// 'regionSymbols' hold values that this memory region is symbolic/parametric
diff --git a/mlir/test/Dialect/Affine/affine-data-copy.mlir b/mlir/test/Dialect/Affine/affine-data-copy.mlir
index 330cf92bafba4..5615acae5ecc4 100644
--- a/mlir/test/Dialect/Affine/affine-data-copy.mlir
+++ b/mlir/test/Dialect/Affine/affine-data-copy.mlir
@@ -300,14 +300,15 @@ func.func @affine_parallel(%85:memref<2x5x4x2xi64>) {
}
}
}
- // CHECK: affine.for
- // CHECK-NEXT: affine.for %{{.*}} = 0 to 5
- // CHECK-NEXT: affine.for %{{.*}} = 0 to 4
- // CHECK-NEXT: affine.for %{{.*}} = 0 to 2
-
+ // Lower and upper bounds for the region can't be determined for the outermost
+ // dimension. No fast buffer generation.
// CHECK: affine.for
// CHECK-NEXT: affine.parallel
// CHECK-NEXT: affine.parallel
+ // CHECK-NEXT: affine.for
+ // CHECK-NOT: affine.for
+
+
return
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/127809
More information about the Mlir-commits
mailing list