[llvm] [MemoryLocation] Support strided matrix loads / stores (PR #163368)
Jon Roelofs via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 22 09:18:00 PDT 2025
================
@@ -288,6 +288,34 @@ MemoryLocation MemoryLocation::getForArgument(const CallBase *Call,
LocationSize::precise(DL.getTypeStoreSize(
II->getArgOperand(1)->getType())),
AATags);
+ case Intrinsic::matrix_column_major_load:
+ case Intrinsic::matrix_column_major_store: {
+ bool IsLoad = II->getIntrinsicID() == Intrinsic::matrix_column_major_load;
+ assert(ArgIdx == (IsLoad ? 0 : 1) && "Invalid argument index");
+
+ auto *Stride = dyn_cast<ConstantInt>(II->getArgOperand(IsLoad ? 1 : 2));
+ uint64_t Rows =
+ cast<ConstantInt>(II->getArgOperand(IsLoad ? 3 : 4))->getZExtValue();
+ uint64_t Cols =
+ cast<ConstantInt>(II->getArgOperand(IsLoad ? 4 : 5))->getZExtValue();
+
+ // The stride is dynamic, so there's nothing we can say.
+ if (!Stride)
+ return MemoryLocation(Arg, LocationSize::afterPointer(), AATags);
+
+ uint64_t ConstStride = Stride->getZExtValue();
+ auto *VT = cast<VectorType>(IsLoad ? II->getType()
+ : II->getArgOperand(0)->getType());
+ assert(Cols != 0 && "Matrix cannot have 0 columns");
+ TypeSize Size = DL.getTypeStoreSize(VT->getScalarType()) *
+ (ConstStride * (Cols - 1) + Rows);
+
+ // In the unstrided case, we have a precise size, ...
+ if (ConstStride == Rows)
----------------
jroelofs wrote:
Can the stride be less than the number of rows? If so, we’d also know the precise size in that case.
https://github.com/llvm/llvm-project/pull/163368
More information about the llvm-commits
mailing list