[Mlir-commits] [mlir] [mlir][vector] Promote in-bounds sub-vector transfer reads with Mem2Reg (PR #236320)

Federico Bruzzone llvmlistbot at llvm.org
Sat Oct 31 03:33:34 PDT 2026


================
@@ -88,6 +90,45 @@ isPromotableTransfer(VectorTransferOpInterface xferOp, const MemorySlot &slot,
   return true;
 }
 
+/// Return constant offsets for a slice contained in the slot vector. Requires:
+/// - Fixed-size vectors of equal rank and element type.
+/// - Identity map and constant nonnegative indices.
+/// - Matching memref/slot shapes, or a zero-offset, unit-stride, same-rank
+///   dynamic subview of a static parent.
+///
+/// Dynamic subview reads use an extent mask to pad outside the runtime extent.
+static FailureOr<SmallVector<int64_t>> getPromotableReadSliceOffsets(
+    TransferReadOp readOp, const MemorySlot &slot,
+    const SmallPtrSetImpl<OpOperand *> &blockingUses) {
+  if (!isTransferSlotAccess(
+          cast<VectorTransferOpInterface>(readOp.getOperation()), slot,
+          blockingUses) ||
+      !readOp.getPermutationMap().isIdentity())
+    return failure();
+
+  auto slotType = dyn_cast<VectorType>(slot.valueType);
+  VectorType readType = readOp.getVectorType();
+  if (!slotType || slotType.isScalable() || readType.isScalable() ||
+      readType.getRank() != slotType.getRank() ||
+      readType.getElementType() != slotType.getElementType())
+    return failure();
+
+  if (!memref::isDynamicSubViewSlot(slot.ptr) &&
+      readOp.getShapedType().getShape() != slotType.getShape())
----------------
FedericoBruzzone wrote:

What case does the `readOp.getShapedType().getShape() != slotType.getShape()` check guard?
Please, document this eventually ;)


https://github.com/llvm/llvm-project/pull/236320


More information about the Mlir-commits mailing list