diff options
author | Dan Gohman <gohman@apple.com> | 2008-10-28 22:38:57 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2008-10-28 22:38:57 +0000 |
commit | b493b2774c23dfb83fa0279718083f686b7c9e5e (patch) | |
tree | 0fe8d5040bab494f2413bde5afb40080a830fb75 /lib/Transforms | |
parent | 2275105edbee89df8f5a68655ee75c9a5f169dbb (diff) |
(A & sext(C)) | (B & ~sext(C) -> C ? A : B
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58351 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 8ec775b0c3..4ec36ad151 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -4337,6 +4337,25 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) { return BinaryOperator::CreateAnd(V1, Or); } } + + // (A & sext(C0)) | (B & ~sext(C0) -> C0 ? A : B + if (isa<SExtInst>(C) && + cast<User>(C)->getOperand(0)->getType() == Type::Int1Ty) { + if (match(D, m_Not(m_Value(C)))) + return SelectInst::Create(cast<User>(C)->getOperand(0), A, B); + // And commutes, try both ways. + if (match(B, m_Not(m_Value(C)))) + return SelectInst::Create(cast<User>(C)->getOperand(0), A, D); + } + // Or commutes, try both ways. + if (isa<SExtInst>(D) && + cast<User>(D)->getOperand(0)->getType() == Type::Int1Ty) { + if (match(C, m_Not(m_Value(D)))) + return SelectInst::Create(cast<User>(D)->getOperand(0), A, B); + // And commutes, try both ways. + if (match(A, m_Not(m_Value(D)))) + return SelectInst::Create(cast<User>(D)->getOperand(0), C, B); + } } // (X >> Z) | (Y >> Z) -> (X|Y) >> Z for all shifts. |