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

Nicolas Vasilache via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 13 03:00:44 PDT 2022


nicolasvasilache added inline comments.


================
Comment at: mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp:1748
+static bool sameValueOrConstantAtIdx(
+    ArrayRef<OpFoldResult> valuesA, ArrayRef<int64_t> constantsA,
+    ArrayRef<OpFoldResult> valuesB, ArrayRef<int64_t> constantsB,
----------------
This feels like a very clunky API to use .. 

Can we merge the OFR and int64_t into a single vector keeping the most static information and only directly compare equality ?

I can't tell offhand if whether this is possible or whether the logic allows for more complex mixings of Value vs int comparisons.


================
Comment at: mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp:1759
 namespace {
 /// Replace reinterpret_cast(extract_strided_metadata memref) -> memref.
 struct ReinterpretCastOpExtractStridedMetadataFolder
----------------
More doc plz, this is much more complex behavior now.

Basically the success cases are:
  1. the source buffer of reinterpret_cast comes from extract_strided_metadata memref and
  2. all offsets, sizes and strides are statically known to be equal. 

Some small IR examples would be good too (fold case and cast case)


================
Comment at: mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp:1800
+    unsigned rank = op.getType().getRank();
+    for (unsigned i = 0; i < rank; ++i)
+      if (!sameValueOrConstantAtIdx(extractStridesOfr, extractStrides,
----------------
multi-line code requires braces


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D135736/new/

https://reviews.llvm.org/D135736



More information about the llvm-commits mailing list