summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-10-11 19:40:04 +0000
committerChris Lattner <sabre@nondot.org>2004-10-11 19:40:04 +0000
commita92af96c56a32a1a7edf0a18cdb8101a6ac3d7cb (patch)
treeadf8c32cd8fd3882887e522bcc99c6b206821b6e /llvm/lib/Transforms
parent58043a1473ca227cf8484a2014cc5d1f0ba19ed9 (diff)
downloadbcm5719-llvm-a92af96c56a32a1a7edf0a18cdb8101a6ac3d7cb.tar.gz
bcm5719-llvm-a92af96c56a32a1a7edf0a18cdb8101a6ac3d7cb.zip
Reenable the transform, turning X/-10 < 1 into X > -10
llvm-svn: 16918
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/InstructionCombining.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
index f663ae6137f..763ffe1d019 100644
--- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/llvm/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)
OpenPOWER on IntegriCloud