[mlir][arith] Allow to specify `constFoldBinaryOp` result type
authorJakub Kuderski <kubak@google.com>
Mon, 13 Feb 2023 19:18:12 +0000 (14:18 -0500)
committerJakub Kuderski <kubak@google.com>
Mon, 13 Feb 2023 19:18:14 +0000 (14:18 -0500)
commit892bf09606b654321c475b503210f30600c3ff7f
treefe58c7ed49f13311a5c4b603454639b79d226697
parentdc38cbcc8b89ea0fa1c6e2be21abe104e19d8c05
[mlir][arith] Allow to specify `constFoldBinaryOp` result type

This enables us to use the common fold helpers on elementwise ops that
produce different result type than operand types, e.g., `arith.cmpi` or
`arith.addui_extended`.

Use the updated helper to teach `arith.cmpi` to fold constant vectors.

Reviewed By: Mogball

Differential Revision: https://reviews.llvm.org/D143779
mlir/include/mlir/Dialect/CommonFolders.h
mlir/lib/Dialect/Arith/IR/ArithOps.cpp
mlir/test/Dialect/Arith/canonicalize.mlir
mlir/test/Dialect/SCF/canonicalize.mlir