[Mlir-commits] [mlir] [mlir][scf] Require positive step when uplifting scf.while (PR #226719)
Ziliang Zhang
llvmlistbot at llvm.org
Sat Oct 3 06:37:33 PDT 2026
================
@@ -165,6 +165,14 @@ FailureOr<scf::ForOp> mlir::scf::upliftWhileToForLoop(RewriterBase &rewriter,
if (!step || !dom.properlyDominates(step, loop))
return rewriter.notifyMatchFailure(loop, "Invalid 'addi' form");
+ // `scf.for` requires a strictly positive step, and the exit-value
+ // reconstruction below relies on that same precondition.
+ APInt stepValue;
+ if (!matchPattern(step, m_ConstantInt(&stepValue)) ||
+ !stepValue.isStrictlyPositive())
+ return rewriter.notifyMatchFailure(loop,
----------------
ziliangzl wrote:
Thanks. How about keep the conservative approach in this PR and implement the runtime fallback in a follow-up PR?
https://github.com/llvm/llvm-project/pull/226719
More information about the Mlir-commits
mailing list