[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:49:11 PDT 2026
================
@@ -84,43 +92,156 @@ getPromotableSubViewOffsets(memref::SubViewOp subView) {
llvm::zip_equal(subView.getMixedSizes(), resType.getShape())) {
std::optional<int64_t> s = getConstantIntValue(size);
if (!s || *s != dim)
- return std::nullopt;
+ return false;
+ }
+ return true;
+}
+
+/// Returns the static offsets of `subView` within the parent vector for
+/// `vector.extract_strided_slice` and `vector.insert_strided_slice`.
+static SmallVector<int64_t> getStaticSubViewOffsets(memref::SubViewOp subView) {
+ SmallVector<int64_t> offsets;
+ for (OpFoldResult offset : subView.getMixedOffsets()) {
+ std::optional<int64_t> value = getConstantIntValue(offset);
+ assert(value && "expected a static offset");
+ offsets.push_back(*value);
}
return offsets;
}
+
+/// Returns whether `subView` can be promoted as an alias of the whole parent
+/// vector. Static shapes are handled by `isAliasableStaticShapeSubView`
+/// instead.
+static bool isAliasableDynamicShapeSubView(memref::SubViewOp subView) {
+ // The parent must be statically shaped so the slot has a fixed-shape vector
+ // type; only the subview's sizes may be dynamic.
+ auto srcType = dyn_cast<MemRefType>(subView.getSource().getType());
+ auto resType = dyn_cast<MemRefType>(subView.getResult().getType());
+ if (!srcType || !resType || !srcType.hasStaticShape())
+ return false;
+
+ // At least one dynamic result dimension; a fully static sub-slice is handled
+ // by `isAliasableStaticShapeSubView` instead.
+ if (resType.hasStaticShape())
----------------
Jianhui-Li wrote:
There are different checks: L120 is to check subview's source memref must be static. Here it checks its result must not be static.
https://github.com/llvm/llvm-project/pull/217793
More information about the Mlir-commits
mailing list