When offsets, sizes and strides are empty, the memref.subview can be
folded into the source. This cannot be done as a folder since a
memref.cast might be required to address the types. Add a
canonicalization pattern for this.
Details
- Reviewers
nicolasvasilache hanchung bondhugula
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp | ||
---|---|---|
635 | This change is not covered by the commit summary and title. |
The revision is making an undocumented change to the DimOp's folder.
mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp | ||
---|---|---|
635 | The whole block above is also missing a comment completely as well. | |
1937 | This isn't the right or efficient way to replace an op's result with another Value in a rewrite pattern. RAUW shouldn't be used here; instead: rewriter.replaceOp(subViewOp, source); |
mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp | ||
---|---|---|
1925 | Consider renaming this to EraseTrivialSubView or TrivialSubViewFolder to be consistent with other such simplifiers. |
Rebase and address comments.
mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp | ||
---|---|---|
1937 | Good catch! Thanks! |
mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp | ||
---|---|---|
1981 | The size of static_offsets acounts for dynamic offsets as well. A -1 is added to static_offsets when the offset is dynamic. (same is true for sizes and strides). The semantics of the subview operation is that missing offsets implies offset is 0, missing sizes implies sizes is same as source size and missing strides implies strides are 1. So all offsets, sizes, and strides missing means that the subview is a no-op. |
FYI, closing this patch as not committing. Ideally memref.subview should not allow number of sizes, offsets and strides that are less than the rank of the source. This should be fixed. I am going to try to tackle that instead.
This change is not covered by the commit summary and title.