forked from OSchip/llvm-project
[mlir][linalg] PadTensorOp vectorization: Avoid redundant FillOps
Do not generate FillOps when these would be entirely overwritten. Differential Revision: https://reviews.llvm.org/D109741
This commit is contained in:
parent
88146230e1
commit
9adc0114bf
|
@ -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());
|
||||
|
|
Loading…
Reference in New Issue