[Mlir-commits] [mlir] [mlir][loops] Reland Refactor LoopFuseSiblingOp and support parallel fusion #94391 (PR #97607)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Wed Jul 3 10:51:19 PDT 2024
================
@@ -113,3 +115,58 @@ LogicalResult detail::verifyLoopLikeOpInterface(Operation *op) {
return success();
}
+
+LoopLikeOpInterface mlir::createFused(LoopLikeOpInterface target,
+ LoopLikeOpInterface source,
+ RewriterBase &rewriter,
+ NewYieldValuesFn newYieldValuesFn,
+ FuseTerminatorFn fuseTerminatorFn) {
+ auto targetIterArgs = target.getRegionIterArgs();
+ std::optional<SmallVector<Value>> targetInductionVar =
+ target.getLoopInductionVars();
+ SmallVector<Value> targetYieldOperands(target.getYieldedValues());
+ auto sourceIterArgs = source.getRegionIterArgs();
+ std::optional<SmallVector<Value>> sourceInductionVar =
+ *source.getLoopInductionVars();
+ SmallVector<Value> sourceYieldOperands(source.getYieldedValues());
+ auto sourceRegion = source.getLoopRegions().front();
+
+ FailureOr<LoopLikeOpInterface> maybeFusedLoop =
+ target.replaceWithAdditionalYields(rewriter, source.getInits(),
+ /*replaceInitOperandUsesInLoop=*/false,
+ newYieldValuesFn);
+ if (failed(maybeFusedLoop))
+ llvm_unreachable("failed to replace loop");
+ LoopLikeOpInterface fusedLoop = *maybeFusedLoop;
+ rewriter.moveOpBefore(fusedLoop, source);
----------------
srcarroll wrote:
done
https://github.com/llvm/llvm-project/pull/97607
More information about the Mlir-commits
mailing list