aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-04-30 22:19:10 +0000
committerChris Lattner <sabre@nondot.org>2003-04-30 22:19:10 +0000
commitfe32e0c578abd1c13a82889217021813d6a29388 (patch)
treeb3e1a03a79d68d7f09d9d2c4206fdda600b84d6c /lib
parent99df25f9f14ffa9c13ddcbfa29ca3bd00d401f1f (diff)
Fix constant folding of constexprs
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5971 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Transforms/Scalar/InstructionCombining.cpp9
1 files changed, 3 insertions, 6 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index 70fc952891..ad4ef420e9 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -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;
}