[Mlir-commits] [mlir] [mlir][arith] Fold addi(x, not(x)) -> -1 (PR #212272)

Victor Perez llvmlistbot at llvm.org
Wed Jul 29 13:50:07 PDT 2026


victor-eds wrote:

> Goos point about `addi(not(x), C) / subi(not(x), C)` it could be canonicalized differently. LLVM really dooesn't perform this hoisting: https://godbolt.org/z/aWK1c1xsf. But it doesn't mean it's worhless

Oh, sure, I am not saying it's "worthless". My understanding though is in `arith` canonicalization/folding, we try to match what LLVM InstCombine does and this would apply a canonicalization "in the opposite direction" to what they do. I agree in some cases this would lead to optimized code (as in the generalization of this folding pattern you propose), but I am not that confident in adding a pattern that explicitly goes in the opposite direction to what they do.

https://github.com/llvm/llvm-project/pull/212272


More information about the Mlir-commits mailing list