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

Chris Lattner lattner at cs.uiuc.edu
Wed Apr 30 17:20:01 PDT 2003


Changes in directory llvm/lib/Transforms/Scalar:

InstructionCombining.cpp updated: 1.79 -> 1.80

---
Log message:

Fix constant folding of constexprs


---
Diffs of the changes:

Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.79 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.80
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.79	Wed Apr 16 17:40:49 2003
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp	Wed Apr 30 17:19:10 2003
@@ -186,12 +186,9 @@
   if (BinaryOperator::isNeg(V))
     return BinaryOperator::getNegArgument(cast<BinaryOperator>(V));
 
-  // Constants can be considered to be negated values...
-  if (Constant *C = dyn_cast<Constant>(V)) {
-    Constant *NC = *Constant::getNullValue(V->getType()) - *C;
-    assert(NC && "Couldn't constant fold a subtract!");
-    return NC;
-  }
+  // Constants can be considered to be negated values if they can be folded...
+  if (Constant *C = dyn_cast<Constant>(V))
+    return *Constant::getNullValue(V->getType()) - *C;
   return 0;
 }
 





More information about the llvm-commits mailing list