diff --git a/mlir/include/mlir/Dialect/SCF/IR/SCF.h b/mlir/include/mlir/Dialect/SCF/IR/SCF.h --- a/mlir/include/mlir/Dialect/SCF/IR/SCF.h +++ b/mlir/include/mlir/Dialect/SCF/IR/SCF.h @@ -60,11 +60,11 @@ bool insideMutuallyExclusiveBranches(Operation *a, Operation *b); /// An owning vector of values, handy to return from functions. -using ValueVector = std::vector; -using LoopVector = std::vector; +using ValueVector = SmallVector; +using LoopVector = SmallVector; struct LoopNest { - ResultRange getResults() { return loops.front().getResults(); } LoopVector loops; + ValueVector results; }; /// Creates a perfect nest of "for" loops, i.e. all loops but the innermost diff --git a/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp b/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp --- a/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp @@ -670,7 +670,7 @@ if (failed(tilePadOp(rewriter, op, newPadOp, loopNest, options))) return failure(); // Replace all uses of the original tensor::PadOp. - rewriter.replaceOp(op, loopNest.getResults()[0]); + rewriter.replaceOp(op, loopNest.results.front()); return success(); } diff --git a/mlir/lib/Dialect/SCF/IR/SCF.cpp b/mlir/lib/Dialect/SCF/IR/SCF.cpp --- a/mlir/lib/Dialect/SCF/IR/SCF.cpp +++ b/mlir/lib/Dialect/SCF/IR/SCF.cpp @@ -520,7 +520,7 @@ assert(results.size() == iterArgs.size() && "loop nest body must return as many values as loop has iteration " "arguments"); - return LoopNest(); + return LoopNest{{}, std::move(results)}; } // First, create the loop structure iteratively using the body-builder @@ -570,9 +570,9 @@ builder.create(loc, results); // Return the loops. - LoopNest res; - res.loops.assign(loops.begin(), loops.end()); - return res; + ValueVector nestResults; + llvm::copy(loops.front().getResults(), std::back_inserter(nestResults)); + return LoopNest{std::move(loops), std::move(nestResults)}; } LoopNest mlir::scf::buildLoopNest( diff --git a/mlir/test/lib/Dialect/Tensor/TestTensorTransforms.cpp b/mlir/test/lib/Dialect/Tensor/TestTensorTransforms.cpp --- a/mlir/test/lib/Dialect/Tensor/TestTensorTransforms.cpp +++ b/mlir/test/lib/Dialect/Tensor/TestTensorTransforms.cpp @@ -199,7 +199,7 @@ }); if (!nest.loops.empty()) - rewriter.replaceOp(op, nest.getResults()); + rewriter.replaceOp(op, nest.results); else rewriter.replaceOp(op, insertResult);