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

Chris Lattner lattner at cs.uiuc.edu
Tue Jul 6 02:13:02 PDT 2004


Changes in directory llvm/lib/Transforms/Scalar:

InstructionCombining.cpp updated: 1.218 -> 1.219

---
Log message:

Fix a minor bug where we would go into infinite loops on some constants


---
Diffs of the changes:  (+2 -1)

Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.218 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.219
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.218	Tue Jul  6 02:01:22 2004
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp	Tue Jul  6 02:11:42 2004
@@ -846,7 +846,8 @@
 Instruction *InstCombiner::visitRem(BinaryOperator &I) {
   if (I.getType()->isSigned())
     if (Value *RHSNeg = dyn_castNegVal(I.getOperand(1)))
-      if (RHSNeg != I.getOperand(1)) {           // Avoid problems with MININT
+      if (!isa<ConstantSInt>(RHSNeg) ||
+          cast<ConstantSInt>(RHSNeg)->getValue() >= 0) {
         // X % -Y -> X % Y
         AddUsesToWorkList(I);
         I.setOperand(1, RHSNeg);





More information about the llvm-commits mailing list