diff options
| author | Sanjay Patel <spatel@rotateright.com> | 2016-12-19 18:35:37 +0000 |
|---|---|---|
| committer | Sanjay Patel <spatel@rotateright.com> | 2016-12-19 18:35:37 +0000 |
| commit | 5a443ac000c667302135f0c4735cb3c98bac1763 (patch) | |
| tree | 76f81858aa7e6f1bd3d53e4d9366ef6e8c608a97 /llvm/lib/Transforms | |
| parent | 05bf3ec4c48b0b9e4dc0d68cc975e6987228411e (diff) | |
| download | bcm5719-llvm-5a443ac000c667302135f0c4735cb3c98bac1763.tar.gz bcm5719-llvm-5a443ac000c667302135f0c4735cb3c98bac1763.zip | |
[InstCombine] use commutative matcher for pattern with commutative operators
This is a case that was missed in:
https://reviews.llvm.org/rL290067
...and it would regress if we fix operand complexity (PR28296).
llvm-svn: 290127
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp index 2ab76d6f8ea..52b611faefa 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp @@ -2263,9 +2263,11 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) { match(Op1, m_Xor(m_Specific(A), m_Specific(B)))) return BinaryOperator::CreateXor(A, B); - // (A ^ B) | ( A & (~B)) -> (A ^ B) - if (match(Op0, m_Xor(m_Value(A), m_Value(B))) && - match(Op1, m_And(m_Specific(A), m_Not(m_Specific(B))))) + // Commute the 'or' operands. + // (A ^ B) | (A & ~B) -> (A ^ B) + // (A ^ B) | (~B & A) -> (A ^ B) + if (match(Op1, m_c_And(m_Value(A), m_Not(m_Value(B)))) && + match(Op0, m_Xor(m_Specific(A), m_Specific(B)))) return BinaryOperator::CreateXor(A, B); // (A & C)|(B & D) |

