diff options
author | Chris Lattner <sabre@nondot.org> | 2004-02-23 05:47:48 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-02-23 05:47:48 +0000 |
commit | 45aaafef49d02ee3df68ee88ad5b680d68a5b961 (patch) | |
tree | da14c1a759c807577a75ca1351b3aea6828932cd /lib/Transforms/Scalar | |
parent | fb54b2b744019ee5ebf5383a3657826861a16184 (diff) | |
download | external_llvm-45aaafef49d02ee3df68ee88ad5b680d68a5b961.zip external_llvm-45aaafef49d02ee3df68ee88ad5b680d68a5b961.tar.gz external_llvm-45aaafef49d02ee3df68ee88ad5b680d68a5b961.tar.bz2 |
Implement "strength reduction" of X <= C and X >= C
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11735 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar')
-rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 9 |
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 |