[Mlir-commits] [mlir] [mlir][TilingInterface] Use `LoopLikeOpInterface` in tiling using SCF to unify tiling with `scf.for` and `scf.forall`. (PR #77874)
lorenzo chelini
llvmlistbot at llvm.org
Fri Jan 12 07:42:18 PST 2024
================
@@ -230,48 +344,48 @@ static void addInitOperandsToLoopNest(
auto newRegionIterArgs = newLoop.getRegionIterArgs();
sourceBlockArgs.append(
newRegionIterArgs.begin(),
- std::next(newRegionIterArgs.begin(), loop.getNumResults()));
- rewriter.mergeBlocks(loop.getBody(), newLoop.getBody(), sourceBlockArgs);
- rewriter.replaceOp(loop,
- newLoop.getResults().take_front(loop.getNumResults()));
+ std::next(newRegionIterArgs.begin(), forLoop.getNumResults()));
+ rewriter.mergeBlocks(forLoop.getBody(), newLoop.getBody(), sourceBlockArgs);
+ rewriter.replaceOp(
+ forLoop, newLoop.getResults().take_front(forLoop.getNumResults()));
loop = newLoop;
newInitValues = newLoop.getRegionIterArgs().take_back(newInitValues.size());
}
// Update the loop body of the innermost loop to get new yield values.
- scf::ForOp innerMostLoop = loops.back();
- auto innerMostYieldOp =
- cast<scf::YieldOp>(innerMostLoop.getBody()->getTerminator());
- rewriter.setInsertionPoint(innerMostYieldOp);
- SmallVector<Value> newYieldVals =
- getNewYieldValsFn(rewriter, innerMostLoop.getInductionVar(),
- innerMostLoop.getRegionIterArgs());
- SmallVector<Value> newYieldOperands =
- llvm::to_vector(innerMostYieldOp->getOperands());
- newYieldOperands.append(newYieldVals);
- rewriter.replaceOpWithNewOp<scf::YieldOp>(innerMostYieldOp, newYieldOperands);
+ LoopLikeOpInterface innerMostLoop = loops.back();
+ FailureOr<LoopLikeOpInterface> newInnerMostLoop =
+ innerMostLoop.replaceWithAdditionalYields(rewriter, newInitValues, false,
+ getNewYieldValsFn);
+ if (failed(newInnerMostLoop)) {
----------------
chelini wrote:
nit: drop braces here?
https://github.com/llvm/llvm-project/pull/77874
More information about the Mlir-commits
mailing list