This is an archive of the discontinued LLVM Phabricator instance.

[mlir][arith] Add narrowing pattern to commute extension over insertion
ClosedPublic

Authored by kuhar on Apr 26 2023, 12:32 PM.

Details

Summary

This enabled more optimization opportunities by moving
zero/sign-extension closer to the use.

Diff Detail

Event Timeline

kuhar created this revision.Apr 26 2023, 12:32 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 26 2023, 12:32 PM
kuhar requested review of this revision.Apr 26 2023, 12:32 PM
kuhar updated this revision to Diff 517271.Apr 26 2023, 12:35 PM

Add missing testcase

antiagainst accepted this revision.Apr 28 2023, 12:35 PM
antiagainst added inline comments.
mlir/lib/Dialect/Arith/Transforms/IntNarrowing.cpp
297

Worth to put some comments here to explain what this is for and why we require it > inserted/dest bitwidth. Something like "Get the immediate destination/result type bitwidth for insert. It's the the intermediate bitwidth intercepting op chains involving extension ops; so we need to make sure it's larger than the required bitwidths needed to represent both the inserted value and the destination value."

mlir/test/Dialect/Arith/int-narrowing.mlir
306

This would actually fold with your https://reviews.llvm.org/D149286?

This revision is now accepted and ready to land.Apr 28 2023, 12:35 PM
kuhar updated this revision to Diff 518034.Apr 28 2023, 1:15 PM
kuhar marked 2 inline comments as done.

Add comments

mlir/test/Dialect/Arith/int-narrowing.mlir
306

It won't fold after createOrFold but will disappear after canonicalization.

This revision was landed with ongoing or failed builds.Apr 28 2023, 1:19 PM
This revision was automatically updated to reflect the committed changes.