From 9244df60d3a9f61bf078071ec0ba98151fa94ddc Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 30 Apr 2003 22:19:10 +0000 Subject: Fix constant folding of constexprs llvm-svn: 5971 --- llvm/lib/Transforms/Scalar/InstructionCombining.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'llvm/lib') diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp index 70fc952891f..ad4ef420e9d 100644 --- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp @@ -186,12 +186,9 @@ static inline Value *dyn_castNegVal(Value *V) { if (BinaryOperator::isNeg(V)) return BinaryOperator::getNegArgument(cast(V)); - // Constants can be considered to be negated values... - if (Constant *C = dyn_cast(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(V)) + return *Constant::getNullValue(V->getType()) - *C; return 0; } -- cgit v1.2.3