[DAGCombiner] Add fold for `~x + x` -> `-1`
authorNoah Goldstein <goldstein.w.n@gmail.com>
Tue, 7 Mar 2023 00:14:46 +0000 (18:14 -0600)
committerNoah Goldstein <goldstein.w.n@gmail.com>
Tue, 7 Mar 2023 02:30:27 +0000 (20:30 -0600)
commitc1ecd0a3f49a39295cde65334357be8fee2ecab9
tree347c93e276b2d9bb95425d931093aacd3cefa211
parentd4b24b4a55822a78ab9435979ecf470e1dc1aef2
[DAGCombiner] Add fold for `~x + x` -> `-1`

This is generally done by the InstCombine, but can be emitted as an
intermediate step and is cheap to handle.

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D145177
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/test/CodeGen/X86/combine-add.ll