[InstCombine] Negator: 'or' with no common bits set is just 'add'
authorRoman Lebedev <lebedev.ri@gmail.com>
Tue, 28 Apr 2020 10:20:04 +0000 (13:20 +0300)
committerRoman Lebedev <lebedev.ri@gmail.com>
Tue, 28 Apr 2020 16:16:32 +0000 (19:16 +0300)
commita0004358a8e7f6956b8b59998e99f4ea8ee201f3
treed64836549b49532761366633a95b4c32280162c4
parenta5f22f2b0ef26265fec7a23367b2044182d39384
[InstCombine] Negator: 'or' with no common bits set is just 'add'

In `InstCombiner::visitAdd()`, we have
```
  // A+B --> A|B iff A and B have no bits set in common.
  if (haveNoCommonBitsSet(LHS, RHS, DL, &AC, &I, &DT))
    return BinaryOperator::CreateOr(LHS, RHS);
```
so we should handle such `or`'s here, too.
llvm/lib/Transforms/InstCombine/InstCombineInternal.h
llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp
llvm/test/Transforms/InstCombine/sub-of-negatible.ll