[Mlir-commits] [llvm] [mlir] [MLIR][AMDGPU] Adding dynamic size check to avoid subword buffer load (PR #135014)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Mon Apr 14 08:35:26 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();
----------------
Max191 wrote:
nit: Create a constexpr variable for the attr name in this file. Something like:
https://github.com/llvm/llvm-project/blob/092b6e73e651469527662443b592f98f442ece72/mlir/lib/Dialect/SCF/Transforms/LoopSpecialization.cpp#L249-L250
https://github.com/llvm/llvm-project/pull/135014
More information about the Mlir-commits
mailing list