[PATCH] D146724: [mlir][MemRef] Add patterns to extract address computations

Quentin Colombet via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 23 07:52:30 PDT 2023


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

This patch adds patterns to rewrite memory accesses such that the resulting
accesses are only using a base pointer.
E.g.,

  mlir
  memref.load %base[%off0, ...]

Will be rewritten in:

  mlir
  %new_base = memref.subview %base[%off0,...][1,...][1,...]
  memref.load %new_base[%c0,...]

The idea behind these patterns is to offer a way to more gradually lower
address computations.

These patterns are the exact opposite of FoldMemRefAliasOps.
I've implemented the support of only three operations in this patch:

- memref.load
- memref.store
- nvgpu.ldmatrix

Going forward we may want to provide an interface for these rewritings (and
the ones in FoldMemRefAliasOps.)
One step at a time!


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146724

Files:
  mlir/include/mlir/Dialect/MemRef/Transforms/Passes.h
  mlir/lib/Dialect/MemRef/Transforms/CMakeLists.txt
  mlir/lib/Dialect/MemRef/Transforms/ExtractAddressComputations.cpp
  mlir/test/Dialect/MemRef/extract-address-computations.mlir
  mlir/test/lib/Dialect/MemRef/CMakeLists.txt
  mlir/test/lib/Dialect/MemRef/TestExtractAddressComputations.cpp
  mlir/tools/mlir-opt/mlir-opt.cpp
  utils/bazel/llvm-project-overlay/mlir/BUILD.bazel

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D146724.507740.patch
Type: text/x-patch
Size: 25076 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230323/7b40fdb0/attachment.bin>


More information about the llvm-commits mailing list