OSDN Git Service

[InstCombine] remove fold that swaps xor/or with constants; NFCI
authorSanjay Patel <spatel@rotateright.com>
Wed, 10 May 2017 21:33:55 +0000 (21:33 +0000)
committerSanjay Patel <spatel@rotateright.com>
Wed, 10 May 2017 21:33:55 +0000 (21:33 +0000)
commit3ba25d2222701517a0e00ba189a1d47b58fb7359
tree8c1e6577baa74388580be7b19fddd98bb385eed1
parentc11234753fec87e1eda13842f6161b031dadae7d
[InstCombine] remove fold that swaps xor/or with constants; NFCI

// (X ^ C1) | C2 --> (X | C2) ^ (C1&~C2)

This canonicalization was added at:
https://reviews.llvm.org/rL7264

By moving xors out/down, we can more easily combine constants. I'm adding
tests that do not change with this patch, so we can verify that those kinds
of transforms are still happening.

This is no-functional-change-intended because there's a later fold:
// (X^C)|Y -> (X|Y)^C iff Y&C == 0
...and demanded-bits appears to guarantee that any fold that would have
hit the fold we're removing here would be caught by that 2nd fold.

Similar reasoning was used in:
https://reviews.llvm.org/rL299384

The larger motivation for removing this code is that it could interfere with
the fix for PR32706:
https://bugs.llvm.org/show_bug.cgi?id=32706

Ie, we're not checking if the 'xor' is actually a 'not', so we could reverse
a 'not' optimization and cause an infinite loop by altering an 'xor X, -1'.

Differential Revision: https://reviews.llvm.org/D33050

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302733 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
test/Transforms/InstCombine/or-xor.ll