[Mlir-commits] [mlir] [mlir][transform] Guard parametric loop tiling pass from no option (PR #118254)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Sun Dec 1 21:47:51 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlir-scf

Author: Kai Sasaki (Lewuathe)

<details>
<summary>Changes</summary>

`test-extract-fixed-outer-loops` pass always crash without any `test-outer-loop-sizes` option. We need to keep the pass from crash by checking the option existence. 

Fix https://github.com/llvm/llvm-project/issues/116360, https://github.com/llvm/llvm-project/issues/116360

---
Full diff: https://github.com/llvm/llvm-project/pull/118254.diff


2 Files Affected:

- (added) mlir/test/Transforms/invalid-outer-loop-size.mlir (+19) 
- (modified) mlir/test/lib/Dialect/SCF/TestLoopParametricTiling.cpp (+3) 


``````````diff
diff --git a/mlir/test/Transforms/invalid-outer-loop-size.mlir b/mlir/test/Transforms/invalid-outer-loop-size.mlir
new file mode 100644
index 00000000000000..42e5848b9704ed
--- /dev/null
+++ b/mlir/test/Transforms/invalid-outer-loop-size.mlir
@@ -0,0 +1,19 @@
+// RUN: mlir-opt -test-extract-fixed-outer-loops %s | FileCheck %s 
+
+// COMMON-LABEL: @no_crash
+func.func @no_crash(%arg0: memref<?x?xf32>) {
+  // CHECK: %[[c2:.*]] = arith.constant 2 : index
+  %c2 = arith.constant 2 : index
+  // CHECK: %[[c44:.*]] = arith.constant 44 : index
+  %c44 = arith.constant 44 : index
+  // CHECK: %[[c1:.*]] = arith.constant 1 : index  
+  %c1 = arith.constant 1 : index
+  // CHECK: scf.for %[[i:.*]] = %[[c2]] to %[[c44]] step %[[c1]]
+  scf.for %i = %c2 to %c44 step %c1 {
+    // CHECK: scf.for %[[j:.*]] = %[[c1]] to %[[c44]] step %[[c2]]
+    scf.for %j = %c1 to %c44 step %c2 {
+      memref.load %arg0[%i, %j]: memref<?x?xf32>
+    }
+  }
+  return
+}
diff --git a/mlir/test/lib/Dialect/SCF/TestLoopParametricTiling.cpp b/mlir/test/lib/Dialect/SCF/TestLoopParametricTiling.cpp
index 1f33a04b0668a9..f90371a27e7393 100644
--- a/mlir/test/lib/Dialect/SCF/TestLoopParametricTiling.cpp
+++ b/mlir/test/lib/Dialect/SCF/TestLoopParametricTiling.cpp
@@ -40,6 +40,9 @@ class SimpleParametricLoopTilingPass
   }
 
   void runOnOperation() override {
+    // If no outer loop iteration is given, ignore the pass.
+    if (sizes.empty())
+      return;
     getOperation()->walk([this](scf::ForOp op) {
       // Ignore nested loops.
       if (op->getParentRegion()->getParentOfType<scf::ForOp>())

``````````

</details>


https://github.com/llvm/llvm-project/pull/118254


More information about the Mlir-commits mailing list