diff options
| author | Fabian Mora <fmora.dev@gmail.com> | 2025-07-02 10:10:03 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-02 10:10:03 -0400 |
| commit | bca79ec0d21e582901b77038121dd3d738ff6aae (patch) | |
| tree | 877192a327e8a4d3f23cce4ef193d27cef438472 /mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp | |
| parent | ebcf7f91ffa09bcc2970367280b3cea85dcfd052 (diff) | |
[mlir][linalg] Use `ub.poison` in linalg vectorizer instead of `0` for some transfer ops (#146544)
This patch is a follow up to https://github.com/llvm/llvm-project/pull/146088 and changes the padding value in the linalg vectorizer from `0` to `ub.poison` in `vector.transfer_read`s created for extracting slices or when vectorizing a generic.
Signed-off-by: Fabian Mora <fabian.mora-cordero@amd.com>
Diffstat (limited to 'mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp')
| -rw-r--r-- | mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp b/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp index b467114c72f7..f8592e2ca217 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp @@ -1183,10 +1183,6 @@ vectorizeTensorExtract(RewriterBase &rewriter, VectorizationState &state, auto srcRank = extractOp.getTensor().getType().getRank(); SmallVector<bool> inBounds(dstRank, true); - // Get the value to pad transfer reads with 0. - Value padding = - arith::getZeroConstant(rewriter, loc, resultType.getElementType()); - // 2a. Handle scalar broadcast access. if (memAccessKind == VectorMemoryAccessKind::ScalarBroadcast) { MLIRContext *ctx = rewriter.getContext(); @@ -1194,8 +1190,8 @@ vectorizeTensorExtract(RewriterBase &rewriter, VectorizationState &state, auto permutationMap = AffineMap::get(srcRank, 0, exprs, ctx); auto transferReadOp = rewriter.create<vector::TransferReadOp>( - loc, resultType, extractOp.getTensor(), transferReadIdxs, padding, - permutationMap, inBounds); + loc, resultType, extractOp.getTensor(), transferReadIdxs, + /*padding=*/std::nullopt, permutationMap, inBounds); // Mask this broadcasting xfer_read here rather than relying on the generic // path (the generic path assumes identity masking map, which wouldn't be @@ -1231,8 +1227,8 @@ vectorizeTensorExtract(RewriterBase &rewriter, VectorizationState &state, } auto transferReadOp = rewriter.create<vector::TransferReadOp>( - loc, resultType, extractOp.getTensor(), transferReadIdxs, padding, - permutationMap, inBounds); + loc, resultType, extractOp.getTensor(), transferReadIdxs, + /*padding=*/std::nullopt, permutationMap, inBounds); LDBG("Vectorised as contiguous load: " << extractOp); return VectorizationHookResult{VectorizationHookStatus::NewOp, @@ -1444,7 +1440,7 @@ vectorizeAsLinalgGeneric(RewriterBase &rewriter, VectorizationState &state, Operation *read = rewriter.create<vector::TransferReadOp>( loc, readType, opOperand->get(), indices, - /*padding=*/arith::getZeroConstant(rewriter, loc, elemType), readMap); + /*padding=*/std::nullopt, readMap); read = state.maskOperation(rewriter, read, linalgOp, indexingMap); Value readValue = read->getResult(0); @@ -2646,7 +2642,7 @@ LogicalResult mlir::linalg::vectorizeCopy(RewriterBase &rewriter, Value readValue = rewriter.create<vector::TransferReadOp>( loc, readType, copyOp.getSource(), indices, - /*padding=*/arith::getZeroConstant(rewriter, loc, srcElementType), + /*padding=*/std::nullopt, rewriter.getMultiDimIdentityMap(srcType.getRank())); if (cast<VectorType>(readValue.getType()).getRank() == 0) { readValue = |
