diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2011-02-20 15:20:01 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2011-02-20 15:20:01 +0000 |
commit | 38f7f66fcc6ed5e43be4d9c96c782d4eabdb7342 (patch) | |
tree | e117a80e124b10e4448809d8a0aa1d7d7dee6c2c /lib/Transforms/InstCombine/InstCombineAndOrXor.cpp | |
parent | 91e37ef278779c3c8700bbddbb5c9d37739b1716 (diff) | |
download | external_llvm-38f7f66fcc6ed5e43be4d9c96c782d4eabdb7342.zip external_llvm-38f7f66fcc6ed5e43be4d9c96c782d4eabdb7342.tar.gz external_llvm-38f7f66fcc6ed5e43be4d9c96c782d4eabdb7342.tar.bz2 |
Move "A | ~(A & ?) -> -1" from InstCombine to InstructionSimplify.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126082 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/InstCombine/InstCombineAndOrXor.cpp')
-rw-r--r-- | lib/Transforms/InstCombine/InstCombineAndOrXor.cpp | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp index 07069ad..7986d1a 100644 --- a/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp +++ b/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp @@ -1919,24 +1919,16 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) { // A | ~(A | B) -> A | ~B // A | ~(A ^ B) -> A | ~B - // A | ~(A & B) -> -1 if (match(Op1, m_Not(m_Value(A)))) if (BinaryOperator *B = dyn_cast<BinaryOperator>(A)) - if (Op0 == B->getOperand(0) || Op0 == B->getOperand(1)) - switch (B->getOpcode()) { - default: break; - case Instruction::Or: - case Instruction::Xor: - if (Op1->hasOneUse()) { - Value *NotOp = Op0 == B->getOperand(0) ? B->getOperand(1) : - B->getOperand(0); - Value *Not = Builder->CreateNot(NotOp, NotOp->getName()+".not"); - return BinaryOperator::CreateOr(Not, Op0); - } - break; - case Instruction::And: - return ReplaceInstUsesWith(I, Constant::getAllOnesValue(I.getType())); - } + if ((Op0 == B->getOperand(0) || Op0 == B->getOperand(1)) && + Op1->hasOneUse() && (B->getOpcode() == Instruction::Or || + B->getOpcode() == Instruction::Xor)) { + Value *NotOp = Op0 == B->getOperand(0) ? B->getOperand(1) : + B->getOperand(0); + Value *Not = Builder->CreateNot(NotOp, NotOp->getName()+".not"); + return BinaryOperator::CreateOr(Not, Op0); + } if (ICmpInst *RHS = dyn_cast<ICmpInst>(I.getOperand(1))) if (ICmpInst *LHS = dyn_cast<ICmpInst>(I.getOperand(0))) |