From: Chris Lattner Date: Mon, 1 Dec 2008 05:16:26 +0000 (+0000) Subject: simplify these patterns using m_Specific. No need to grep for X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=d8aafcb200bf413a5f477148b7f4ff6d6ea31e2d;p=oota-llvm.git simplify these patterns using m_Specific. No need to grep for xor in testcase (or is a substring). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60328 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 11c5f752977..bc8744480c5 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -3980,22 +3980,12 @@ Instruction *InstCombiner::visitAnd(BinaryOperator &I) { } // (A&((~A)|B)) -> A&B - if (match(Op0, m_Or(m_Not(m_Value(A)), m_Value(B)))) { - if (A == Op1) - return BinaryOperator::CreateAnd(A, B); - } - if (match(Op0, m_Or(m_Value(A), m_Not(m_Value(B))))) { - if (B == Op1) - return BinaryOperator::CreateAnd(A, B); - } - if (match(Op1, m_Or(m_Not(m_Value(A)), m_Value(B)))) { - if (A == Op0) - return BinaryOperator::CreateAnd(A, B); - } - if (match(Op1, m_Or(m_Value(A), m_Not(m_Value(B))))) { - if (B == Op0) - return BinaryOperator::CreateAnd(A, B); - } + if (match(Op0, m_Or(m_Not(m_Specific(Op1)), m_Value(A))) || + match(Op0, m_Or(m_Value(A), m_Not(m_Specific(Op1))))) + return BinaryOperator::CreateAnd(A, Op1); + if (match(Op1, m_Or(m_Not(m_Specific(Op0)), m_Value(A))) || + match(Op1, m_Or(m_Value(A), m_Not(m_Specific(Op0))))) + return BinaryOperator::CreateAnd(A, Op0); } if (ICmpInst *RHS = dyn_cast(Op1)) { diff --git a/test/Transforms/InstCombine/and-not-or.ll b/test/Transforms/InstCombine/and-not-or.ll index b183b216e9d..9e9f397c4be 100644 --- a/test/Transforms/InstCombine/and-not-or.ll +++ b/test/Transforms/InstCombine/and-not-or.ll @@ -1,6 +1,4 @@ -; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep {and i32 %y, %x} | count 2 -; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep {and i32 %x, %y} | count 2 -; RUN: llvm-as < %s | opt -instcombine | llvm-dis | not grep {xor} +; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep {and i32 %x, %y} | count 4 ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | not grep {or} define i32 @func1(i32 %x, i32 %y) nounwind {