summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@gmail.com>2017-04-10 06:53:21 +0000
committerCraig Topper <craig.topper@gmail.com>2017-04-10 06:53:21 +0000
commit4738321f0c7cfc8a94c49e420fa0b7f1c1f8421a (patch)
tree84674e41416e8108046a79496bf2daf0f7fe5e8a
parent4f16d82d6b572647ae281289f96a5068430e1581 (diff)
downloadbcm5719-llvm-4738321f0c7cfc8a94c49e420fa0b7f1c1f8421a.tar.gz
bcm5719-llvm-4738321f0c7cfc8a94c49e420fa0b7f1c1f8421a.zip
[InstCombine] Make the (A|B)^B -> A & ~B transform code consistent with the very similar (A&B)^B -> ~A & B code. This should be NFC except for the addition of hasOneUse check.
I think this code is still overly complicated and should use matchers, but first I wanted to make it consistent. llvm-svn: 299834
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
index 5b2dbd9d1f3..091c80daef6 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
@@ -2504,12 +2504,12 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) {
BinaryOperator *Op1I = dyn_cast<BinaryOperator>(Op1);
if (Op1I) {
Value *A, *B;
- if (match(Op1I, m_Or(m_Value(A), m_Value(B)))) {
- if (A == Op0) { // B^(B|A) == (A|B)^B
+ if (match(Op1I, m_OneUse(m_Or(m_Value(A), m_Value(B))))) {
+ if (A == Op0) { // A^(A|B) == A^(B|A)
Op1I->swapOperands();
- I.swapOperands();
- std::swap(Op0, Op1);
- } else if (B == Op0) { // B^(A|B) == (A|B)^B
+ std::swap(A, B);
+ }
+ if (B == Op0) { // A^(B|A) == (B|A)^A
I.swapOperands(); // Simplified below.
std::swap(Op0, Op1);
}
OpenPOWER on IntegriCloud