diff options
author | Chris Lattner <sabre@nondot.org> | 2003-11-04 23:37:10 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-11-04 23:37:10 +0000 |
commit | 0f68fa6569f14b7b76647e4d0e156f1e56d7b11b (patch) | |
tree | 0b86b782886b2d07ef673da154b2b8502a4b29f8 /llvm/lib/Transforms/Scalar/InstructionCombining.cpp | |
parent | e3a932c6d04af17581d1c1ae5e9d86c6014009cc (diff) | |
download | bcm5719-llvm-0f68fa6569f14b7b76647e4d0e156f1e56d7b11b.tar.gz bcm5719-llvm-0f68fa6569f14b7b76647e4d0e156f1e56d7b11b.zip |
Implement InstCombine/xor.ll:test(15|16)
llvm-svn: 9708
Diffstat (limited to 'llvm/lib/Transforms/Scalar/InstructionCombining.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/InstructionCombining.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp index 27801895402..88026c30d55 100644 --- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp @@ -1002,7 +1002,14 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) { SCI->getOperand(0), SCI->getOperand(1)); if (ConstantInt *Op0CI = dyn_cast<ConstantInt>(Op0I->getOperand(1))) - if (Op0I->getOpcode() == Instruction::And) { + if (Op0I->getOpcode() == Instruction::Add) { + // ~(X-c) --> (-c-1)-X + if (RHS->isAllOnesValue()) + return BinaryOperator::create(Instruction::Sub, + *-*Op0CI - + *ConstantInt::get(I.getType(), 1), + Op0I->getOperand(0)); + } else if (Op0I->getOpcode() == Instruction::And) { // (X & C1) ^ C2 --> (X & C1) | C2 iff (C1&C2) == 0 if ((*RHS & *Op0CI)->isNullValue()) return BinaryOperator::create(Instruction::Or, Op0, RHS); |