[PATCH] D134577: [mlir][MemRef] Simplify extract_strided_metadata(allocLikeOp)

Quentin Colombet via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 23 17:18:09 PDT 2022


qcolombet created this revision.
qcolombet added reviewers: chelini, nicolasvasilache.
qcolombet added a project: MLIR.
Herald added subscribers: bzcheeseman, sdasgup3, Groverkss, wenzhicui, wrengr, cota, teijeong, rdzhabarov, tatianashp, msifontes, jurahul, Kayjukh, grosul1, Joonsoo, liufengdb, aartbik, mgester, arpith-jacob, antiagainst, shauheen, rriddle, mehdi_amini.
Herald added a project: All.
qcolombet requested review of this revision.
Herald added a subscriber: stephenneuendorffer.

Teach the pass that simplifies extract_strided_metadata(other_op(memref))
how to get rid of extract_strided_metadata when they are fed by
allocLikeOp.

For the simplification to happen the allocLikeOp needs to have been
normalized. I.e., no weird offset and strides.

When this is the case, we replace:

  base, offset, sizes, strides =
      extract_strided_metadata(allocLikeOp(allocSizes))

With

  base = reinterpret_cast allocLikeOp(allocSizes) to a flat memref<eltTy>
  offset = 0 
  sizes = allocSizes
  strides#i = prod(allocSizes#j, for j in {i+1..rank-1})

The computation involving dynamic sizes are expanded in affine.apply.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D134577

Files:
  mlir/lib/Dialect/MemRef/Transforms/SimplifyExtractStridedMetadata.cpp
  mlir/test/Dialect/MemRef/simplify-extract-strided-metadata.mlir

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134577.462628.patch
Type: text/x-patch
Size: 13137 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220924/2754683c/attachment.bin>


More information about the llvm-commits mailing list