This is an archive of the discontinued LLVM Phabricator instance.

[mlir][MemRef] Move the forwarding patterns for `extract_strided_metadata`
ClosedPublic

Authored by qcolombet on Oct 12 2022, 10:49 AM.

Details

Summary

The SimplifyExtractStridedMetadata pass features a pattern that forward statically known information (offset, sizes, strides) to their respective users.

This patch moves this pattern from this pass to the extract_strided_metadata folding patterns.

Diff Detail

Event Timeline

qcolombet created this revision.Oct 12 2022, 10:49 AM
qcolombet requested review of this revision.Oct 12 2022, 10:49 AM
nicolasvasilache accepted this revision.Oct 13 2022, 3:01 AM
This revision is now accepted and ready to land.Oct 13 2022, 3:01 AM
This revision was landed with ongoing or failed builds.Oct 18 2022, 3:35 PM
This revision was automatically updated to reflect the committed changes.
Hardcode84 added inline comments.
mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp
1328

Here replaceConstantUsesOf creates new ops and replaces uses of op being folded. Is this even legal to do this from the folder? How it will interoperate with greedy rewriter which has no way to know new ops were created or uses were changed?

This should probably be an canonicalization pattern and not folder.

qcolombet added inline comments.
mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp
1328

Is this even legal to do this from the folder?

Good question, I didn't realize this was the first time such folding pattern was introduced.

@nicolasvasilache, @ftynse, @mehdi_amini what do you think?

How it will interoperate with greedy rewriter which has no way to know new ops were created or uses were changed?

IIRC that part was working just fine, but to be fair, I don't remember if I was testing more than just the lowering of memref (I think I was, but not sure).
If I am not mistaken the ::create method will notify the listener that something has been added.