Page MenuHomePhabricator

[mlir][memref] memref.reinterpret_cast folding
ClosedPublic

Authored by Hardcode84 on Feb 21 2022, 4:20 AM.

Details

Summary
  • reinterpret_cast(reinterpret_cast(x)) -> reinterpret_cast(x)
  • reinterpret_cast(cast(x)) -> reinterpret_cast(x)
  • reinterpret_cast(subview(x)) -> reinterpret_cast(x) if subview offsets are 0

Diff Detail

Event Timeline

Hardcode84 created this revision.Feb 21 2022, 4:20 AM
Hardcode84 requested review of this revision.Feb 21 2022, 4:20 AM

fix gcc build

These are all pretty useful - thanks!

mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp
1511–1536

Please add comments along the lines you have in the commit summary.

1521

Avoid suffixed names like is0.

add comments

Hardcode84 added inline comments.Feb 21 2022, 10:02 AM
mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp
1521

Sorry, I didn't quite get this comment. Renamed to isZeroVal anyway.

bondhugula added inline comments.Feb 21 2022, 6:23 PM
mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp
1521

isZero was what I meant instead of is0. This is fine now.

Herald added a project: Restricted Project. · View Herald TranscriptMar 2 2022, 6:10 AM
nicolasvasilache accepted this revision.Mar 11 2022, 5:52 AM
nicolasvasilache added inline comments.
mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp
1525

Could you add a isConstantIntValue(OpFoldResult, int64_t) to the utils and use it here?

1529

This would become:

if (llvm::all_of(prev.getMixedOffsets(), [](OpFoldResult val){ return isConstantIntValue(val, 0); }))
  ...
This revision is now accepted and ready to land.Mar 11 2022, 5:52 AM

rebase, review comments

Hardcode84 marked 2 inline comments as done.Mar 11 2022, 6:41 AM
mlir/include/mlir/Dialect/Utils/StaticValueUtils.h
56

nit: typo

mlir/lib/Dialect/Utils/StaticValueUtils.cpp
84

nit: typo

This revision was automatically updated to reflect the committed changes.
Hardcode84 marked 2 inline comments as done.Mar 11 2022, 10:24 AM