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

Chris Lattner lattner at cs.uiuc.edu
Fri Oct 8 19:50:52 PDT 2004



Changes in directory llvm/lib/Transforms/Scalar:

InstructionCombining.cpp updated: 1.264 -> 1.265
---
Log message:

Implement sub.ll:test17, -X/C -> X/-C


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

Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.264 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.265
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.264	Fri Oct  8 14:15:44 2004
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp	Fri Oct  8 21:50:40 2004
@@ -946,6 +946,11 @@
           return new ShiftInst(Instruction::Shr, I.getOperand(0),
                                ConstantUInt::get(Type::UByteTy, C));
 
+    // -X/C -> X/-C
+    if (RHS->getType()->isSigned())
+      if (Value *LHSNeg = dyn_castNegVal(I.getOperand(0)))
+        return BinaryOperator::createDiv(LHSNeg, ConstantExpr::getNeg(RHS));
+
     if (isa<PHINode>(I.getOperand(0)) && !RHS->isNullValue())
       if (Instruction *NV = FoldOpIntoPhi(I))
         return NV;






More information about the llvm-commits mailing list