This utility factors out the machinery required to add iterArgs and yield values to an scf.ForOp.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
mlir/include/mlir/Transforms/LoopUtils.h | ||
---|---|---|
297 | Nit: newYieldedValues -> newIterOperands | |
mlir/lib/Transforms/Utils/LoopUtils.cpp | ||
2533 | Why not create this in the right block to start with? | |
2540 | Would bvm.map(loop.region().front().getArguments(), newLoop.region().front().getArguments().take_front(loop.region().front().getNumArguments())) work? | |
2545 | Same here? | |
2550 | How about using without_terminator()here? | |
2554 | bvm.map(o.getResults(), cloned->getResults())? |
It feels like this should live in SCF rather than LoopUtils, it's not anyhow generic.
mlir/lib/Transforms/Utils/LoopUtils.cpp | ||
---|---|---|
2529 | Would loop.body().getTerminator() work instead? | |
2540 | Could we make it a bit shorter by, e.g., caching the result of loop.region().front() in a variable loopBody? | |
2554 | I think this is already done inside clone, no need to do it manually | |
2566 | This is not allowed if OpBuilder is a ConversionRewriter, use b.eraseOp instead |
mlir/lib/Transforms/Utils/LoopUtils.cpp | ||
---|---|---|
2566 | Hmm... but there is no OpBuilder::eraseOp; it only exists in PatternRewriters. |
mlir/include/mlir/IR/Builders.h | ||
---|---|---|
465 ↗ | (On Diff #267075) | OpBuilder was refactored to use the Listener pattern instead of virtual methods. If we agree that we want to have eraseOp on OpBuilder, it should also go through the listener. |
mlir/include/mlir/Transforms/LoopUtils.h | ||
323 | My commit-level comment might have gone unnoticed, so reiterating here: "It feels like this should live in SCF rather than LoopUtils, it's not anyhow generic." | |
mlir/lib/Transforms/Utils/LoopUtils.cpp | ||
2566 | Good point, @bondhugula ! @nicolasvasilache do you intend to use this in a place where no PatternRewriter is available? If not, just take a PatternRewriter& instead of OpBuilder& and be done with it. |
Nit: newYieldedValues -> newIterOperands