This is an archive of the discontinued LLVM Phabricator instance.

Canonicalization for add to no-op if one of the inputs is zero
ClosedPublic

Authored by not-jenni on Nov 4 2021, 11:11 AM.

Diff Detail

Event Timeline

not-jenni created this revision.Nov 4 2021, 11:11 AM
not-jenni requested review of this revision.Nov 4 2021, 11:11 AM
not-jenni added a subscriber: KoolJBlack.
rsuderman accepted this revision.Nov 4 2021, 4:50 PM
This revision is now accepted and ready to land.Nov 4 2021, 4:50 PM
This revision was automatically updated to reflect the committed changes.
Mogball added a subscriber: Mogball.Nov 4 2021, 5:35 PM

Nice! I assume sub(x, 0) -> x is next?

jpienaar added inline comments.
mlir/lib/Dialect/Tosa/IR/TosaOps.cpp
309

You can match with m_Zero too

316

If tosa add is still marked commutative, then you only need one of these (https://mlir.llvm.org/docs/Canonicalization/#globally-applied-rules)