[Mlir-commits] [mlir] [mlir][affine] Clamp negative static trip counts to zero (PR #227134)

Jeremy Kun llvmlistbot at llvm.org
Fri Oct 2 17:00:15 PDT 2026


================
@@ -709,6 +709,24 @@ func.func @unroll_zero_trip_count_case() {
   return
 }
 
+// The upper bounds are below the lower bounds, so neither loop executes.
+// UNROLL-FULL-LABEL: func @unroll_zero_trip_count_nonconstant_bounds
+func.func @unroll_zero_trip_count_nonconstant_bounds(%N: index) {
+  // UNROLL-FULL:      affine.for
----------------
j2kun wrote:

This is consistent with the test above `unroll_zero_trip_count_case`, and not blocking this PR from being merged, but I am curious why a zero-iteration loop remains in the IR. Wouldn't "unrolling" a zero-iteration loop be equivalent to removing it?

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


More information about the Mlir-commits mailing list