[Mlir-commits] [mlir] [mlir][Vector] Promote buffers accessed via dynamic subviews and memref.copy (PR #217793)

Jianhui Li llvmlistbot at llvm.org
Tue Oct 13 10:51:47 PDT 2026


================
@@ -37,45 +51,39 @@
 using namespace mlir;
 using namespace mlir::memref;
 using namespace mlir::vector;
-
 //===----------------------------------------------------------------------===//
-//  memref.subview aliaser
+//  Utilities
 //===----------------------------------------------------------------------===//
 
-/// Returns the offsets of `subView` as a static, contiguous, same-rank slice of
-/// its source, or nullopt if the subview is not promotable as a whole-buffer
-/// sub-slice. Promotion projects the parent buffer's vector value through
-/// `vector.extract_strided_slice` / `insert_strided_slice`, which require:
+/// Returns whether `subView` can be promoted as an alias of a sub-vector.
+/// Promotion uses `vector.extract_strided_slice` and
+/// `vector.insert_strided_slice`, which require:
 ///   * fully static offsets and sizes,
 ///   * unit strides,
 ///   * no rank reduction (result rank == source rank),
-/// so a dropped or dynamic dimension disqualifies the subview.
-static std::optional<SmallVector<int64_t>>
-getPromotableSubViewOffsets(memref::SubViewOp subView) {
+/// Dynamic shapes are handled by `isAliasableDynamicShapeSubView` instead.
+static bool isAliasableStaticShapeSubView(memref::SubViewOp subView) {
   auto srcType = dyn_cast<MemRefType>(subView.getSource().getType());
   auto resType = dyn_cast<MemRefType>(subView.getResult().getType());
   if (!srcType || !resType || !srcType.hasStaticShape() ||
       !resType.hasStaticShape())
-    return std::nullopt;
+    return false;
 
   // No rank reduction: extract/insert_strided_slice operate at a single rank.
   if (srcType.getRank() != resType.getRank())
-    return std::nullopt;
+    return false;
 
   // Unit strides only.
----------------
Jianhui-Li wrote:

Yes. Since it promotes static subview access to extract/insert_strided_slice, so it is contrained by those op sementics.

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


More information about the Mlir-commits mailing list