[llvm] [mlir] [MLIR][AMDGPU] Adding dynamic size check to avoid subword buffer load (PR #135014)
Zhuoran Yin via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 14 14:11:21 PDT 2025
================
@@ -101,13 +110,32 @@ static LogicalResult transferPreconditions(
return success();
}
+static Value createVectorLoadForMaskedLoad(OpBuilder &builder, Location loc,
+ vector::TransferReadOp readOp,
+ bool requiresBroadcasting,
+ VectorType unbroadcastedVectorType) {
+ Value fill = builder.create<vector::SplatOp>(loc, unbroadcastedVectorType,
+ readOp.getPadding());
+ Value load = builder.create<vector::LoadOp>(
+ loc, unbroadcastedVectorType, readOp.getSource(), readOp.getIndices());
+ Value res = builder.create<arith::SelectOp>(loc, unbroadcastedVectorType,
+ readOp.getMask(), load, fill);
+ // Insert a broadcasting op if required.
+ if (requiresBroadcasting) {
+ res = builder.create<vector::BroadcastOp>(loc, readOp.getVectorType(), res);
+ }
+ return res;
+}
+
namespace {
struct TransferReadLowering final : OpRewritePattern<vector::TransferReadOp> {
using OpRewritePattern::OpRewritePattern;
LogicalResult matchAndRewrite(vector::TransferReadOp readOp,
PatternRewriter &rewriter) const override {
+ if (readOp->hasAttr("amdgpu.buffer_transfer_read_needs_mask"))
+ return failure();
----------------
jerryyin wrote:
Good point!
https://github.com/llvm/llvm-project/pull/135014
More information about the llvm-commits
mailing list