[mlir][arith] Canonicalize `addi(x, muli(y, -1))` -> `subi(x, y)`
authorJakub Kuderski <kubak@google.com>
Tue, 7 Mar 2023 00:28:39 +0000 (19:28 -0500)
committerJakub Kuderski <kubak@google.com>
Tue, 7 Mar 2023 00:28:39 +0000 (19:28 -0500)
commitfbe91fe2cc3bd2c907e63f30db719204aaaf3973
tree8070b06bcbf8657667abd6ffc63696c5037b3c0e
parent260bae5ba27cde110590c28941966a6e02df5325
[mlir][arith] Canonicalize `addi(x, muli(y, -1))` -> `subi(x, y)`

These propagate all the way down to SPIR-V and result in some fishy code
with large constants.

Reviewed By: antiagainst

Differential Revision: https://reviews.llvm.org/D145423
mlir/lib/Dialect/Arith/IR/ArithCanonicalization.td
mlir/lib/Dialect/Arith/IR/ArithOps.cpp
mlir/test/Dialect/Arith/canonicalize.mlir