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 | 59611149ee33d432c29c9a55a0f1e9e8baa2d114 (patch) | |
tree | 98090bee67961eae086bb4618a5e3ebc829a25a3 /llvm/lib/Transforms | |
parent | 2635b52d4ef70e38cd70d7acbc80388eb443edd2 (diff) | |
download | bcm5719-llvm-59611149ee33d432c29c9a55a0f1e9e8baa2d114.tar.gz bcm5719-llvm-59611149ee33d432c29c9a55a0f1e9e8baa2d114.zip |
Implement "strength reduction" of X <= C and X >= C
llvm-svn: 11735
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/Scalar/InstructionCombining.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp index d12674d3bf7..f23c10fcbd8 100644 --- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/llvm/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 |