[llvm-commits] [llvm] r60369 - /llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp

Bill Wendling isanbard at gmail.com
Mon Dec 1 13:03:43 PST 2008


Author: void
Date: Mon Dec  1 15:03:43 2008
New Revision: 60369

URL: http://llvm.org/viewvc/llvm-project?rev=60369&view=rev
Log:
Document what this check is doing. Also, no need to cast to ConstantInt.

Modified:
    llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=60369&r1=60368&r2=60369&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Mon Dec  1 15:03:43 2008
@@ -2933,10 +2933,10 @@
     // -X/C -> X/-C, if and only if negation doesn't overflow.
     if (Value *LHSNeg = dyn_castNegVal(Op0)) {
       if (ConstantInt *CI = dyn_cast<ConstantInt>(LHSNeg)) {
-        ConstantInt *RHSNeg = cast<ConstantInt>(ConstantExpr::getNeg(RHS));
-        if (RHS != RHSNeg) {
-          ConstantInt *CINeg = cast<ConstantInt>(ConstantExpr::getNeg(CI));
-          if (CI != CINeg)
+        Constant *RHSNeg = ConstantExpr::getNeg(RHS);
+        if (RHS != RHSNeg) {    // Check that there is no overflow.
+          Constant *CINeg = ConstantExpr::getNeg(CI);
+          if (CI != CINeg)      // Check that there is no overflow.
             return BinaryOperator::CreateSDiv(LHSNeg,
                                               ConstantExpr::getNeg(RHS));
         }





More information about the llvm-commits mailing list