This is an archive of the discontinued LLVM Phabricator instance.

[mlir][bufferization] Canonicalizer to skip extract_strided_metadata when operand is already a base memref.
ClosedPublic

Authored by maerhart on Aug 7 2023, 12:40 AM.

Details

Summary

The extract_strided_metadata will be heavily used by the new buffer deallocation pass to get the base memref and pass it to the deallocation operation. This commit factors out some simplification logic of the pass into a canonicalization pattern.

Diff Detail

Event Timeline

maerhart created this revision.Aug 7 2023, 12:40 AM
Herald added a project: Restricted Project. · View Herald Transcript
maerhart requested review of this revision.Aug 7 2023, 12:40 AM
springerm added inline comments.Aug 7 2023, 12:57 AM
mlir/lib/Dialect/Bufferization/IR/BufferizationOps.cpp
1001–1010

The combination of m_AllOf and m_AnyOf (which is just needed to capture the value?) is a bit confusing. I would write this without matchers:

auto extractStridedOp = memref.getDefiningOp<ExtractStridedMetadataOp>();
if (!extractStridedOp) return failure();
auto allocOp = extractStridedOp.getSource().getDefiningOp<MemoryEffectOpInterface>();
if (!allocOp) return failure();
if (allocOp.getEffectOnValue ...)
maerhart updated this revision to Diff 548501.Aug 9 2023, 12:51 AM

Use regular getDefiningOp chain instead of pattern matching

maerhart edited the summary of this revision. (Show Details)Aug 9 2023, 12:52 AM
springerm accepted this revision.Aug 9 2023, 6:32 AM
This revision is now accepted and ready to land.Aug 9 2023, 6:32 AM