aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms/Scalar
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Transforms/Scalar')
-rw-r--r--lib/Transforms/Scalar/InstructionCombining.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index d12674d..f23c10f 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -1369,6 +1369,15 @@ Instruction *InstCombiner::visitSetCondInst(BinaryOperator &I) {
if (I.getOpcode() == Instruction::SetLE) // A <= MAX-1 -> A != MAX
return BinaryOperator::create(Instruction::SetNE, Op0, AddOne(CI));
}
+
+ // If we still have a setle or setge instruction, turn it into the
+ // appropriate setlt or setgt instruction. Since the border cases have
+ // already been handled above, this requires little checking.
+ //
+ if (I.getOpcode() == Instruction::SetLE)
+ return BinaryOperator::create(Instruction::SetLT, Op0, AddOne(CI));
+ if (I.getOpcode() == Instruction::SetGE)
+ return BinaryOperator::create(Instruction::SetGT, Op0, SubOne(CI));
}
// Test to see if the operands of the setcc are casted versions of other