This is an archive of the discontinued LLVM Phabricator instance.

[mlir][arith] Add initial integer bitwidth narrowing pass
ClosedPublic

Authored by kuhar on Apr 24 2023, 8:49 PM.

Details

Summary

This pass reduces the logical complexity of arith ops by choosing
narrowest supported operand bitwidth. On some targets like mobile GPUs,
narrower bitwidths also bring better runtime performance.

The first batch of rewrites handles a simple case of arith.sitofp
and arith.uitofp with zero/sign-extended inputs. In future revisions,
I plan to extend it with the following:

  • Propagating sign/zero-extensions through bit-pattern-preserving ops, e.g., vector transpose, broadcast, insertions/extractions.
  • Handling linalg.index using the ValueBounds interface.
  • Handling more arith ops.

Diff Detail

Event Timeline

kuhar created this revision.Apr 24 2023, 8:49 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 24 2023, 8:49 PM
kuhar requested review of this revision.Apr 24 2023, 8:49 PM
antiagainst accepted this revision.Apr 25 2023, 3:27 PM

Cool, stuff. LGTM for the first version as a basis!

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

Also add tests for cases where we have:

  • Consecutive extension ops of the same kind
  • Consecutive extension ops of different kinds

to check the recursive aspect

This revision is now accepted and ready to land.Apr 25 2023, 3:27 PM
kuhar updated this revision to Diff 516965.Apr 25 2023, 3:59 PM

Add test cases with consecutive extensions

kuhar marked an inline comment as done.Apr 25 2023, 3:59 PM
springerm accepted this revision.Apr 25 2023, 6:30 PM
springerm added inline comments.
mlir/test/Dialect/Arith/int-narrowing.mlir
12

Put // ----- between tests, otherwise --split-input-file has no effect.

kuhar updated this revision to Diff 517022.Apr 25 2023, 7:24 PM
kuhar marked an inline comment as done.

Drop --split-file

This revision was landed with ongoing or failed builds.Apr 25 2023, 7:34 PM
This revision was automatically updated to reflect the committed changes.