[Mlir-commits] [mlir] [mlir][xegpu] Add support for `vector.transfer_read/write` on SLM buffers (PR #192757)
Charitha Saumya
llvmlistbot at llvm.org
Thu Apr 23 14:51:01 PDT 2026
================
@@ -547,31 +547,67 @@ struct TransferReadLowering : public OpRewritePattern<vector::TransferReadOp> {
if (failed(transferPreconditions(rewriter, readOp)))
return failure();
+ auto readMemTy = cast<MemRefType>(readOp.getShapedType());
+ VectorType loadedVecTy = readOp.getVectorType();
+ bool isOutOfBounds = readOp.hasOutOfBoundsDim();
+ // Check if the memref has address space 3 (shared local memory)
+ bool isSharedMemory = xegpu::XeGPUDialect::isSharedMemory(readMemTy);
// TODO:This check needs to be replaced with proper uArch capability check
auto chip = xegpu::getChipStr(readOp);
- if (chip != "pvc" && chip != "bmg") {
- // lower to scattered load Op if the target HW doesn't have 2d block load
- // support
+ // Lower to scattered load Op if the target HW doesn't have 2d block load
+ // support and the load is not from shared memory.
+ if (chip != "pvc" && chip != "bmg" && !isSharedMemory) {
+
// TODO: add support for OutOfBound access
- if (readOp.hasOutOfBoundsDim())
+ if (isOutOfBounds)
return failure();
return lowerToScatteredLoadOp(readOp, rewriter);
}
- VectorType loadedVecTy = readOp.getVectorType();
-
- // Lower using load.gather in 1D case
- if (loadedVecTy.getRank() == 1 && !readOp.hasOutOfBoundsDim())
+ // Handle the 1D non-SLM case using load.gather.
+ if (loadedVecTy.getRank() == 1 && !isOutOfBounds && !isSharedMemory)
return lowerToScatteredLoadOp(readOp, rewriter);
// Perform common data transfer checks.
- auto readMemTy = cast<MemRefType>(readOp.getShapedType());
+ // TODO: Maybe too strict for SLM case.
if (failed(
storeLoadPreconditions(rewriter, readOp, loadedVecTy, readMemTy)))
return failure();
- bool isOutOfBounds = readOp.hasOutOfBoundsDim();
+ // Handle the SLM case.
+ if (isSharedMemory) {
----------------
charithaintc wrote:
I tried to do this. But then `storeLoadPreconditions` can not be moved to front without failing some tests. The checks inside only applies to SLM case or ND case and does not apply to 1D non-SLM case using load.gather cases.
I suggest refactoring the code when adding SLM support for vector.load/store ops?
https://github.com/llvm/llvm-project/pull/192757
More information about the Mlir-commits
mailing list