mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-20 16:17:38 +00:00
InstCombine: (sub (or A B) (xor A B)) --> (and A B)
The following implements the transformation: (sub (or A B) (xor A B)) --> (and A B). Patch by Ankur Garg! Differential Revision: http://reviews.llvm.org/D5719 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220163 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -1621,6 +1621,15 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) {
|
||||
return BinaryOperator::CreateNeg(Y);
|
||||
}
|
||||
|
||||
// (sub (or A, B) (xor A, B)) --> (and A, B)
|
||||
{
|
||||
Value *A = nullptr, *B = nullptr;
|
||||
if (match(Op1, m_Xor(m_Value(A), m_Value(B))) &&
|
||||
(match(Op0, m_Or(m_Specific(A), m_Specific(B))) ||
|
||||
match(Op0, m_Or(m_Specific(B), m_Specific(A)))))
|
||||
return BinaryOperator::CreateAnd(A, B);
|
||||
}
|
||||
|
||||
if (Op1->hasOneUse()) {
|
||||
Value *X = nullptr, *Y = nullptr, *Z = nullptr;
|
||||
Constant *C = nullptr;
|
||||
|
||||
Reference in New Issue
Block a user