[mlir][Arith] Pass to switch signed ops for equivalent unsigned ones
authorKrzysztof Drewniak <Krzysztof.Drewniak@amd.com>
Thu, 14 Apr 2022 22:51:23 +0000 (22:51 +0000)
committerKrzysztof Drewniak <Krzysztof.Drewniak@amd.com>
Tue, 14 Jun 2022 21:18:29 +0000 (21:18 +0000)
commitb0b00432093be9680ed833af642bcafc3ca11586
tree0f49cd1a4568f774714db24840f54b8bc64180b0
parent657e954939c8a7d33c40291ef3214333a1e2ca5b
[mlir][Arith] Pass to switch signed ops for equivalent unsigned ones

If all the arguments to and results of an operation are known to be
non-negative when interpreted as signed (which also implies that all
computations producing those values did not experience signed
overflow), we can replace that operation with an equivalent one that
operates on unsigned values.

Such a replacement, when it is possible, can provide useful hints to
backends, such as by allowing LLVM to replace remainder with bitwise
operations in more cases.

Depends on D124022

Depends on D124023

Reviewed By: Mogball

Differential Revision: https://reviews.llvm.org/D124024
mlir/include/mlir/Dialect/Arithmetic/Transforms/Passes.h
mlir/include/mlir/Dialect/Arithmetic/Transforms/Passes.td
mlir/lib/Dialect/Arithmetic/Transforms/CMakeLists.txt
mlir/lib/Dialect/Arithmetic/Transforms/UnsignedWhenEquivalent.cpp [new file with mode: 0644]
mlir/test/Dialect/Arithmetic/unsigned-when-equivalent.mlir [new file with mode: 0644]