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 | 91ccc15b454e10f6c0bd3b66fff5fcd84f3c19c2 (patch) | |
tree | 078b9d6395fbf6f0db416b5bf7b13ef1e138bdc9 /lib | |
parent | 24c0532f50bd08b71fb81b55407f739e3d070fad (diff) | |
download | external_llvm-91ccc15b454e10f6c0bd3b66fff5fcd84f3c19c2.zip external_llvm-91ccc15b454e10f6c0bd3b66fff5fcd84f3c19c2.tar.gz external_llvm-91ccc15b454e10f6c0bd3b66fff5fcd84f3c19c2.tar.bz2 |
Instcombine: -(X sdiv C) -> (X sdiv -C), tested by sub.ll:test16
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16769 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 6db0717..767fc95 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/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 = |