diff options
author | Chad Rosier <mcrosier@apple.com> | 2012-04-26 23:29:14 +0000 |
---|---|---|
committer | Chad Rosier <mcrosier@apple.com> | 2012-04-26 23:29:14 +0000 |
commit | 7813dcee3060665e310dbb5e3d286c9bca346572 (patch) | |
tree | b1c14fda3eadb3c4c2815802746ed269fc2ad853 /llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp | |
parent | 16d0d6c4ad5f2d99775439c6a9cf75dc64a6a8ef (diff) | |
download | bcm5719-llvm-7813dcee3060665e310dbb5e3d286c9bca346572.tar.gz bcm5719-llvm-7813dcee3060665e310dbb5e3d286c9bca346572.zip |
Add instcombine patterns for the following transformations:
(x & y) | (x ^ y) -> x | y
(x & y) + (x ^ y) -> x | y
Patch by Manman Ren.
rdar://10770603
llvm-svn: 155674
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp index 05e702fa43b..6a39fc33d48 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp @@ -329,6 +329,20 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) { } } + // Check for (x & y) + (x ^ y) + { + Value *A = 0, *B = 0; + if (match(RHS, m_Xor(m_Value(A), m_Value(B))) && + (match(LHS, m_And(m_Specific(A), m_Specific(B))) || + match(LHS, m_And(m_Specific(B), m_Specific(A))))) + return BinaryOperator::CreateOr(A, B); + + if (match(LHS, m_Xor(m_Value(A), m_Value(B))) && + (match(RHS, m_And(m_Specific(A), m_Specific(B))) || + match(RHS, m_And(m_Specific(B), m_Specific(A))))) + return BinaryOperator::CreateOr(A, B); + } + return Changed ? &I : 0; } |