[Mlir-commits] [mlir] [mlir][DialectUtils] Fix 0 step handling in `constantTripCount` (PR #177329)
Matthias Springer
llvmlistbot at llvm.org
Thu Jan 22 08:06:29 PST 2026
================
@@ -357,9 +357,15 @@ func.func @regression(%arg0: memref<i64>, %arg1: index) {
// -----
// Regression test: Make sure that we do not crash.
-// The step is 0, the loop will be eliminated.
+
// CHECK-LABEL: func @zero_step(
-// CHECK-NOT: scf.for
+// CHECK: %[[c0:.*]] = arith.constant 0
+// CHECK: %[[c1:.*]] = arith.constant 1
+// CHECK: %[[poison:.*]] = ub.poison
----------------
matthias-springer wrote:
This feels like a problem of the loop peeling transformation to me. Loop peeling is not well-defined when you have a step size of 0.
```
/// Rewrite a for loop with bounds/step that potentially do not divide evenly
/// into a for loop where the step divides the iteration space evenly, followed
/// by an scf.if for the last (partial) iteration (if any).
```
This part: **`step divides the iteration space evenly`**
https://github.com/llvm/llvm-project/pull/177329
More information about the Mlir-commits
mailing list