[InstCombine] Fold `(~x) | y` --> `~(x & (~y))` iff it is free to do so
authorRoman Lebedev <lebedev.ri@gmail.com>
Fri, 22 Jan 2021 09:58:45 +0000 (12:58 +0300)
committerRoman Lebedev <lebedev.ri@gmail.com>
Fri, 22 Jan 2021 14:23:54 +0000 (17:23 +0300)
commitd1a6f92fd545726aab0784e2dcfb193ce185c418
treedf34ec55b11c69c87bc96aaeab00e726fa61a888
parent79b0d21ce92f1a5ff4c822d1a5c664196b338535
[InstCombine] Fold `(~x) | y` --> `~(x & (~y))` iff it is free to do so

Iff we know we can get rid of the inversions in the new pattern,
we can thus get rid of the inversion in the old pattern,
this decreasing instruction count.

Note that we could position this transformation as just hoisting
of the `not` (still, iff y is freely negatible), but the test changes
show a number of regressions, so let's not do that.
llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
llvm/lib/Transforms/InstCombine/InstCombineInternal.h
llvm/test/Transforms/InstCombine/sink-not-into-another-hand-of-or.ll
llvm/test/Transforms/SimplifyCFG/merge-cond-stores.ll