[Mlir-commits] [mlir] [mlir] Add splitForOpAtBound utility and use it in loop unrolling (PR #215108)

Matthias Springer llvmlistbot at llvm.org
Wed Aug 26 00:07:21 PDT 2026


================
@@ -363,6 +364,112 @@ void mlir::generateUnrolledLoop(
   loopBodyBlock->getTerminator()->setOperands(lastYielded);
 }
 
+/// Splits `forOp` into two consecutive loops at `splitPoint`.
+FailureOr<std::pair<scf::ForOp, scf::ForOp>>
+mlir::splitForOpAtPoint(scf::ForOp forOp, Value splitPoint) {
----------------
matthias-springer wrote:

Let's pass in a `RewriterBase &` instead of creating a new builder in the function body. Then this helper can be used from rewrite patterns, transforms ops, etc. Also make sure to use the rewriter instead of `forOp.erase()` etc.

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


More information about the Mlir-commits mailing list