[Mlir-commits] [mlir] [MLIR][SCF] Handle more cases in pipelining transform (PR #74007)
Quinn Dawkins
llvmlistbot at llvm.org
Fri Dec 1 18:00:49 PST 2023
================
@@ -418,9 +446,30 @@ LogicalResult LoopPipelinerInternal::createKernel(
// We create a mapping between original values and the associated loop
// returned values that will be needed by the epilogue.
llvm::SmallVector<Value> yieldOperands;
- for (Value retVal : forOp.getBody()->getTerminator()->getOperands()) {
- yieldOperands.push_back(mapping.lookupOrDefault(retVal));
+ for (OpOperand &yielOperand :
+ forOp.getBody()->getTerminator()->getOpOperands()) {
+ Value source = mapping.lookupOrDefault(yielOperand.get());
+ // When we don't peel the epilogue the yield value is used outside the loop
+ // we need to make sure we return the version from numStages - defStage.
+ if (!peelEpilogue &&
+ !forOp.getResult(yielOperand.getOperandNumber()).use_empty()) {
+ auto [def, distance] = getDefiningOpAndDistance(yielOperand.get());
+ if (def) {
----------------
qedawkins wrote:
style nit: If you move this into its own lambda function or another helper, you can reduce the amount of nesting with early returns.
https://github.com/llvm/llvm-project/pull/74007
More information about the Mlir-commits
mailing list