]> granicus.if.org Git - llvm/commitdiff
Fix constant folding of constexprs
authorChris Lattner <sabre@nondot.org>
Wed, 30 Apr 2003 22:19:10 +0000 (22:19 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 30 Apr 2003 22:19:10 +0000 (22:19 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5971 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/InstructionCombining.cpp

index 70fc952891fe15c1633e2e68f11685b6477767c0..ad4ef420e9db938df52e3a3afac759a62b131353 100644 (file)
@@ -186,12 +186,9 @@ static inline Value *dyn_castNegVal(Value *V) {
   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;
 }