[llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp

Chris Lattner lattner at cs.uiuc.edu
Sun Feb 22 23:48:01 PST 2004


Changes in directory llvm/lib/Transforms/Scalar:

InstructionCombining.cpp updated: 1.157 -> 1.158

---
Log message:

Implement "strength reduction" of   X <= C and X >= C


---
Diffs of the changes:  (+9 -0)

Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.157 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.158
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.157	Sun Feb 22 23:39:21 2004
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp	Sun Feb 22 23:47:48 2004
@@ -1369,6 +1369,15 @@
       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





More information about the llvm-commits mailing list