diff options
author | Chris Lattner <sabre@nondot.org> | 2003-10-02 15:11:26 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-10-02 15:11:26 +0000 |
commit | 6b032052cc91dd47e22099b70e9757f58c666f37 (patch) | |
tree | 69faed94972845b9ac57d5b13ab3ae148cbd1571 | |
parent | ad5727d173bb44334476478038f77c86a74045d7 (diff) | |
download | external_llvm-6b032052cc91dd47e22099b70e9757f58c666f37.zip external_llvm-6b032052cc91dd47e22099b70e9757f58c666f37.tar.gz external_llvm-6b032052cc91dd47e22099b70e9757f58c666f37.tar.bz2 |
Implement InstCombine/add.ll:test17 & 18
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8817 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index e69db1d..465954a 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -437,6 +437,22 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) { if (Constant *C2 = dyn_castMaskingAnd(RHS)) if (Instruction *R = AssociativeOpt(I, AddMaskingAnd(C2))) return R; + if (ConstantInt *CRHS = dyn_cast<ConstantInt>(RHS)) { + if (Instruction *ILHS = dyn_cast<Instruction>(LHS)) { + switch (ILHS->getOpcode()) { + case Instruction::Xor: + // ~X + C --> (C-1) - X + if (ConstantInt *XorRHS = dyn_cast<ConstantInt>(ILHS->getOperand(1))) + if (XorRHS->isAllOnesValue()) + return BinaryOperator::create(Instruction::Sub, + *CRHS - *ConstantInt::get(I.getType(), 1), + ILHS->getOperand(0)); + break; + default: break; + } + } + } + return Changed ? &I : 0; } |