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 ↗ | (On Diff #266635) | Nit: newYieldedValues -> newIterOperands |
mlir/lib/Transforms/Utils/LoopUtils.cpp | ||
2534 ↗ | (On Diff #266635) | Why not create this in the right block to start with? |
2541 ↗ | (On Diff #266635) | Would bvm.map(loop.region().front().getArguments(), newLoop.region().front().getArguments().take_front(loop.region().front().getNumArguments())) work? |
2546 ↗ | (On Diff #266635) | Same here? |
2551 ↗ | (On Diff #266635) | How about using without_terminator()here? |
2555 ↗ | (On Diff #266635) | 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 | ||
---|---|---|
2530 ↗ | (On Diff #266635) | Would loop.body().getTerminator() work instead? |
2541 ↗ | (On Diff #266635) | Could we make it a bit shorter by, e.g., caching the result of loop.region().front() in a variable loopBody? |
2555 ↗ | (On Diff #266635) | I think this is already done inside clone, no need to do it manually |
2567 ↗ | (On Diff #266635) | This is not allowed if OpBuilder is a ConversionRewriter, use b.eraseOp instead |
mlir/lib/Transforms/Utils/LoopUtils.cpp | ||
---|---|---|
2567 ↗ | (On Diff #266635) | Hmm... but there is no OpBuilder::eraseOp; it only exists in PatternRewriters. |
mlir/lib/Transforms/Utils/LoopUtils.cpp | ||
---|---|---|
2541–2543 ↗ | (On Diff #266635) | Since there's only one region and one block, region().front() -> getBody() / body(). I'm surprised there isn't an accessor. For eg. spirv::LoopOp has a body(). |
2560 ↗ | (On Diff #266635) | Nit: Replace loop's results if ... |
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 ↗ | (On Diff #267075) | 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 | ||
2567 ↗ | (On Diff #266635) | 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. |