[InstCombine] prefer xor with -1 because 'not' is easier to understand (PR32706)
authorSanjay Patel <spatel@rotateright.com>
Wed, 12 Aug 2020 19:21:17 +0000 (15:21 -0400)
committerSanjay Patel <spatel@rotateright.com>
Wed, 12 Aug 2020 19:50:33 +0000 (15:50 -0400)
commit23bd33c6acc4fa0ddc097d3d0767860cc014f6e0
tree020e811f421e8c5f028b13be4a5d79c5170d0791
parent0a1514d7ca4f34bc515f1911f1d33cddf4224a98
[InstCombine] prefer xor with -1 because 'not' is easier to understand (PR32706)

This is a retry of rL300977 which was reverted because of infinite loops.
We have fixed all of the known places where that would happen, but there's
still a chance that this patch will cause infinite loops.

This matches the demanded bits behavior in the DAG and should fix:
https://bugs.llvm.org/show_bug.cgi?id=32706

Differential Revision: https://reviews.llvm.org/D32255
llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
llvm/test/Transforms/InstCombine/and-xor-or.ll
llvm/test/Transforms/InstCombine/or-xor.ll
llvm/test/Transforms/InstCombine/xor.ll