[Mlir-commits] [mlir] 9adc011 - [mlir][linalg] PadTensorOp vectorization: Avoid redundant FillOps
Matthias Springer
llvmlistbot at llvm.org
Tue Sep 14 17:29:01 PDT 2021
Author: Matthias Springer
Date: 2021-09-15T09:28:37+09:00
New Revision: 9adc0114bfeb704ca62d8c369fa52d0530179274
URL: https://github.com/llvm/llvm-project/commit/9adc0114bfeb704ca62d8c369fa52d0530179274
DIFF: https://github.com/llvm/llvm-project/commit/9adc0114bfeb704ca62d8c369fa52d0530179274.diff
LOG: [mlir][linalg] PadTensorOp vectorization: Avoid redundant FillOps
Do not generate FillOps when these would be entirely overwritten.
Differential Revision: https://reviews.llvm.org/D109741
Added:
Modified:
mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp b/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp
index 7007d8b1101ac..913fa72dc1f2d 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp
@@ -751,6 +751,13 @@ struct GenericPadTensorOpVectorizationPattern
padOp.getLoc(), vecType, padOp.source(), readIndices, padValue,
readInBounds);
+ // If `dest` is a FillOp and the TransferWriteOp would overwrite the entire
+ // tensor, write directly to the FillOp's operand.
+ if (llvm::equal(vecShape, resultType.getShape())
+ && llvm::all_of(writeInBounds, [](bool b) { return b; }))
+ if (auto fill = dest.getDefiningOp<FillOp>())
+ dest = fill.output();
+
// Generate TransferWriteOp.
auto writeIndices = ofrToIndexValues(
rewriter, padOp.getLoc(), padOp.getMixedLowPad());
More information about the Mlir-commits
mailing list