diff options
| author | Chris Lattner <sabre@nondot.org> | 2004-10-06 15:08:25 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2004-10-06 15:08:25 +0000 |
| commit | 0aee4b7947ef7d4342bad709352e3669bb7b96cb (patch) | |
| tree | c1b3f1886e46ea0bc85a068ef71cac1db656d26e /llvm/lib | |
| parent | 52783ab1d856093782c991c53a45d5b100b25730 (diff) | |
| download | bcm5719-llvm-0aee4b7947ef7d4342bad709352e3669bb7b96cb.tar.gz bcm5719-llvm-0aee4b7947ef7d4342bad709352e3669bb7b96cb.zip | |
Instcombine: -(X sdiv C) -> (X sdiv -C), tested by sub.ll:test16
llvm-svn: 16769
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/InstructionCombining.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp index 6db0717a9fc..767fc9582b0 100644 --- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp @@ -746,6 +746,14 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) { return BinaryOperator::createAnd(Op0, NewNot); } + // -(X sdiv C) -> (X sdiv -C) + if (Op1I->getOpcode() == Instruction::Div) + if (ConstantSInt *CSI = dyn_cast<ConstantSInt>(Op0)) + if (CSI->getValue() == 0) + if (Constant *DivRHS = dyn_cast<Constant>(Op1I->getOperand(1))) + return BinaryOperator::createDiv(Op1I->getOperand(0), + ConstantExpr::getNeg(DivRHS)); + // X - X*C --> X * (1-C) if (dyn_castFoldableMul(Op1I) == Op0) { Constant *CP1 = |

