diff options
| author | Chris Lattner <sabre@nondot.org> | 2007-04-02 05:36:22 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2007-04-02 05:36:22 +0000 |
| commit | b24acc7beefc0715e7a4acce62666164e4e6282b (patch) | |
| tree | 1f3b07f8405de931e0c6fcb8bd8dffbffe8c39b9 /llvm/lib/Transforms/Scalar/InstructionCombining.cpp | |
| parent | 2d81c6d7060fbc7558792730a71307b78f251807 (diff) | |
| download | bcm5719-llvm-b24acc7beefc0715e7a4acce62666164e4e6282b.tar.gz bcm5719-llvm-b24acc7beefc0715e7a4acce62666164e4e6282b.zip | |
simplify (x+c)^signbit as (x+c+signbit), pointed out by PR1288. This implements
test/Transforms/InstCombine/xor.ll:test28
llvm-svn: 35584
Diffstat (limited to 'llvm/lib/Transforms/Scalar/InstructionCombining.cpp')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/InstructionCombining.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp index 87f96674285..3b81be3abfd 100644 --- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp @@ -4005,7 +4005,7 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) { return BinaryOperator::createOr(Op0NotVal, NotY); } } - + if (ConstantInt *Op0CI = dyn_cast<ConstantInt>(Op0I->getOperand(1))) if (Op0I->getOpcode() == Instruction::Add) { // ~(X-c) --> (-c-1)-X @@ -4015,6 +4015,12 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) { ConstantExpr::getSub(NegOp0CI, ConstantInt::get(I.getType(), 1)), Op0I->getOperand(0)); + } else if (RHS->getValue().isMinSignedValue()) { + // (X + C) ^ signbit -> (X + C + signbit) + Constant *C = ConstantInt::get(RHS->getValue() + Op0CI->getValue()); + return BinaryOperator::createAdd(Op0I->getOperand(0), C); + + } } else if (Op0I->getOpcode() == Instruction::Or) { // (X|C1)^C2 -> X^(C1|C2) iff X&~C1 == 0 |

