This is an archive of the discontinued LLVM Phabricator instance.

Several canonicalizations of standard ops (add, sub, cast).
ClosedPublic

Authored by wsmoses on May 1 2021, 7:58 PM.

Details

Summary

Introduce several canonicalizations of standard operations:

  1. Canonicalizatinos for sub/add of a constant and another sub/add of a constant
  2. Sign Extend folds
  3. Not of icmp becomes a signle icmp
  4. Branch propagation
  5. Index cast of sign extend

Diff Detail

Event Timeline

wsmoses created this revision.May 1 2021, 7:58 PM
wsmoses requested review of this revision.May 1 2021, 7:59 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 1 2021, 7:59 PM
wsmoses updated this revision to Diff 342193.May 1 2021, 8:03 PM

Address nits

rriddle added inline comments.May 1 2021, 8:15 PM
mlir/lib/Dialect/StandardOps/IR/Ops.cpp
1778

Don't use ConstantOp, use m_Constant to match constants.

rriddle requested changes to this revision.May 1 2021, 8:16 PM

Can you split this up into several focused commits?

This revision now requires changes to proceed.May 1 2021, 8:16 PM
wsmoses updated this revision to Diff 342205.May 1 2021, 9:15 PM

Remove all canoncalizations exclude the add/sub (factored out into separate diffs)

I wonder if there is some way of writing these without so much repetition...

mlir/lib/Dialect/StandardOps/IR/Ops.cpp
306–307

This may also swap the operands... It is okay for addi, but should be mentioned in the description.

ftynse accepted this revision.May 3 2021, 12:56 AM
This revision was not accepted when it landed; it landed in state Needs Review.May 3 2021, 8:53 AM
This revision was automatically updated to reflect the committed changes.
jpienaar added inline comments.
mlir/lib/Dialect/StandardOps/IR/Ops.cpp
302

Note: addi is commutative and commutative operations have their constant operand canonicalized to RHS. So does this need to check for constants both sides?