[Mlir-commits] [mlir] [mlir][scf] Require positive step when uplifting scf.while (PR #226719)
Ivan Butygin
llvmlistbot at llvm.org
Sat Oct 3 07:10:46 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,
----------------
Hardcode84 wrote:
Sounds good, we can also, potentially, plug integer range analysis and check the value range instead of requiring it to be constant.
https://github.com/llvm/llvm-project/pull/226719
More information about the Mlir-commits
mailing list