[PATCH] D135736: [mlir][MemRef] Make reinterpret_cast(extract_strided_metadata) more robust

Quentin Colombet via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 11 18:29:40 PDT 2022


qcolombet created this revision.
qcolombet added reviewers: nicolasvasilache, chelini.
qcolombet added a project: MLIR.
Herald added subscribers: bzcheeseman, sdasgup3, 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.

Prior to this patch the canonicalization pattern that turns `reinterpret_cast(extract_strided_metadata)` into `cast` was only applied when all the input operands of the `reinterpret_cast` are exactly all the output results of the `extract_strided_metadata`.

This missed simplification opportunities when the values would have hold the same constant values, but yet, come from different actual values.

E.g., prior to this patch, a pattern of the form:

  %base, %offset = extract_strided_metadata %source : memref<i16>
  reinterpret_cast %base to offset:[0]

Wouldn't have been simplified into a simple cast, because %offset is not directly the same value object as 0.

This patch teaches this pattern how to check if the constant values match what the results of the extract_strided_metadata operation would have hold.

Note: This patch will be helpful to keep nice MLIR outputs when I push the patch to do the forwarding of statically known information as part of a folding of `extract_strided_metadata`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D135736

Files:
  mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp
  mlir/test/Dialect/MemRef/canonicalize.mlir

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135736.466989.patch
Type: text/x-patch
Size: 7610 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221012/99610595/attachment.bin>


More information about the llvm-commits mailing list