diff options
| author | Benjamin Kramer <benny.kra@googlemail.com> | 2010-07-12 13:44:00 +0000 |
|---|---|---|
| committer | Benjamin Kramer <benny.kra@googlemail.com> | 2010-07-12 13:44:00 +0000 |
| commit | f578c36035ffba51aa57cfcb294196bce0ae6460 (patch) | |
| tree | 19a89cb290a0be7bc3c5f0db227c0a87baaa4176 /llvm/lib | |
| parent | 11743249e6026bcd2baed363768e3b920ac16a6e (diff) | |
| download | bcm5719-llvm-f578c36035ffba51aa57cfcb294196bce0ae6460.tar.gz bcm5719-llvm-f578c36035ffba51aa57cfcb294196bce0ae6460.zip | |
Reapply 108136 with an ugly pasto fixed.
llvm-svn: 108141
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp index 3f4a857c41a..ccf5cd8581d 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp @@ -1597,6 +1597,14 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) { Instruction *Ret = FoldOrWithConstants(I, Op0, A, V1, D); if (Ret) return Ret; } + + // (A & ~C) | (B & C) -> ((B ^ A) & C) ^ A + if (Op0->hasOneUse() && Op1->hasOneUse() && + match(C, m_Not(m_Specific(D)))) { + Value *Xor = Builder->CreateXor(B, A, "xor"); + Value *And = Builder->CreateAnd(Xor, D, "and"); + return BinaryOperator::CreateXor(And, A); + } } // (X >> Z) | (Y >> Z) -> (X|Y) >> Z for all shifts. @@ -1920,6 +1928,15 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) { return BinaryOperator::CreateAnd(NewOp, X); } } + + // (A & ~C) ^ (B & C) -> ((B ^ A) & C) ^ A + if (Op0->hasOneUse() && Op1->hasOneUse() && + match(Op0I, m_And(m_Value(A), m_Not(m_Value(D)))) && + match(Op1I, m_And(m_Value(B), m_Specific(D)))) { + Value *Xor = Builder->CreateXor(B, A, "xor"); + Value *And = Builder->CreateAnd(Xor, D, "and"); + return BinaryOperator::CreateXor(And, A); + } } // (icmp1 A, B) ^ (icmp2 A, B) --> (icmp3 A, B) |

