[Mlir-commits] [mlir] [mlir][scf] Fix the scf.while result reconstructed by upliftWhileToForLoop (PR #219617)
Matthias Springer
llvmlistbot at llvm.org
Fri Sep 4 04:15:18 PDT 2026
================
@@ -241,11 +241,26 @@ FailureOr<scf::ForOp> mlir::scf::upliftWhileToForLoop(RewriterBase &rewriter,
one = arith::ConstantIntOp::create(rewriter, loc, step.getType(), 1);
}
+ // Not the last executed induction value: `scf.condition` forwards to the
+ // results only once the condition fails, so the escaping value is one step
+ // past anything the body saw, `lb + tripCount * step`, clamped at zero trips
+ // so an entry-false loop reports `lb`.
+ //
+ // Assumes a strictly positive `step`. The matcher does not check this, so a
+ // non-positive step breaks the ceil-div and also builds an `scf.for` that
+ // violates its own contract; pre-existing gap, not repairable here.
+ Value zero;
----------------
matthias-springer wrote:
You can write something like this: `Value zero =
arith::ConstantOp::create(b, loc, b.getZeroAttr(value.getType()));`
https://github.com/llvm/llvm-project/pull/219617
More information about the Mlir-commits
mailing list