diff options
author | Chris Lattner <sabre@nondot.org> | 2004-10-11 19:40:04 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-10-11 19:40:04 +0000 |
commit | 6a9fdfaec8b1a88c32dfbac70207e1e1de689f81 (patch) | |
tree | 40f813633bf488a2ad08a380132fe9afac691f4a /lib | |
parent | c71ff4c34b9dfc5f25fc984da19ef85b0ef37906 (diff) | |
download | external_llvm-6a9fdfaec8b1a88c32dfbac70207e1e1de689f81.zip external_llvm-6a9fdfaec8b1a88c32dfbac70207e1e1de689f81.tar.gz external_llvm-6a9fdfaec8b1a88c32dfbac70207e1e1de689f81.tar.bz2 |
Reenable the transform, turning X/-10 < 1 into X > -10
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16918 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index f663ae6..763ffe1 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -2116,6 +2116,8 @@ Instruction *InstCombiner::visitSetCondInst(BinaryOperator &I) { ConstantInt *Prod; bool ProdOV = MulWithOverflow(Prod, CI, DivRHS); + Instruction::BinaryOps Opcode = I.getOpcode(); + if (DivRHS->isNullValue()) { // Don't hack on divide by zeros. } else if (LHSI->getType()->isUnsigned()) { // udiv LoBound = Prod; @@ -2152,15 +2154,13 @@ Instruction *InstCombiner::visitSetCondInst(BinaryOperator &I) { HiBound = cast<ConstantInt>(ConstantExpr::getSub(Prod, DivRHS)); } - /// FIXME: This code is disabled, because we do not compile the - /// divisor case < 0 correctly. For example, this code is incorrect - /// in the case of "X/-10 < 1". - LoBound = 0; + // Dividing by a negate swaps the condition. + Opcode = SetCondInst::getSwappedCondition(Opcode); } if (LoBound) { Value *X = LHSI->getOperand(0); - switch (I.getOpcode()) { + switch (Opcode) { default: assert(0 && "Unhandled setcc opcode!"); case Instruction::SetEQ: if (LoOverflow && HiOverflow) |