Page MenuHomePhabricator

[mlir][memref] Propagate LoadOp/StoreOp to SubViewOp source where possible
Needs ReviewPublic

Authored by Hardcode84 on Jul 13 2021, 4:08 AM.

Details

Summary
  • Rank-reducing subview is not supported yet
  • Subview offsets must be statically known to be 0s and strides must 1s

Diff Detail

Event Timeline

Hardcode84 created this revision.Jul 13 2021, 4:08 AM
Hardcode84 requested review of this revision.Jul 13 2021, 4:08 AM

Thanks @Hardcode84 !
Note that these patterns cannot remain canonicalizations in general because they will have far reaching consequences.
Can you put them in a new pass?

And what exactly wrong with making them canonicalizations?

They fold away subviews indiscriminately as soon as canonicalization is invoked.
This prematurely drops information that other parts of the compiler want to operate on.
Actually I think @mravishankar implemented similar functionality to fold subview away in the past, not sure whether they made it into core or just IREE?

Hardcode84 added a comment.EditedJul 13 2021, 6:29 AM

Actually, there is a FoldSubViewOpsPass, but it can generate additional ops, which can be undesirable during canonicalization. Here I specifically restricted it in such way it never generates additional ops.

So, what useful information we are losing here? Subview dimensions? Is there any examples they can be usefull in this context?

The only example I can see is someone doing bounds-checked array accesses and doing this very late in pipeline (at memref->llvm lowering level), but this not very good idea in general IMO, regardless of this specific transformation.