This is an archive of the discontinued LLVM Phabricator instance.

[mlir][arith] Add narrowing patterns for `addi` and `muli`
ClosedPublic

Authored by kuhar on Apr 29 2023, 1:33 PM.

Details

Summary

These two ops are handled in a very similar way -- the only difference
in the number result bits produced.

I checked these transformation with Alive2:

  1. addi + sext: https://alive2.llvm.org/ce/z/3NSs9T
  2. addi + zext: https://alive2.llvm.org/ce/z/t7XHOT
  3. muli + sext: https://alive2.llvm.org/ce/z/-7sfW9
  4. muli + zext: https://alive2.llvm.org/ce/z/h4yntF

Diff Detail

Event Timeline

kuhar created this revision.Apr 29 2023, 1:33 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 29 2023, 1:33 PM
kuhar requested review of this revision.Apr 29 2023, 1:33 PM
antiagainst accepted this revision.May 1 2023, 8:28 PM

Neat!

mlir/lib/Dialect/Arith/Transforms/IntNarrowing.cpp
228

You mean : i16 here?

This revision is now accepted and ready to land.May 1 2023, 8:28 PM
This revision was landed with ongoing or failed builds.May 2 2023, 7:11 AM
This revision was automatically updated to reflect the committed changes.
kuhar marked an inline comment as done.
kuhar added inline comments.May 2 2023, 7:12 AM
mlir/lib/Dialect/Arith/Transforms/IntNarrowing.cpp
228

Good catch, thanks!