aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-11-04 23:37:10 +0000
committerChris Lattner <sabre@nondot.org>2003-11-04 23:37:10 +0000
commit689d24b6ed709ea2dbeee5741c0b9ac8c658d92e (patch)
tree183094005bace666f26250dcb3fc29cb7f7e38dc /lib
parent736cca670f9149cc381a519abc2f22e9a720de76 (diff)
downloadexternal_llvm-689d24b6ed709ea2dbeee5741c0b9ac8c658d92e.zip
external_llvm-689d24b6ed709ea2dbeee5741c0b9ac8c658d92e.tar.gz
external_llvm-689d24b6ed709ea2dbeee5741c0b9ac8c658d92e.tar.bz2
Implement InstCombine/xor.ll:test(15|16)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9708 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Transforms/Scalar/InstructionCombining.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index 2780189..88026c3 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/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);