diff options
| author | Chris Lattner <sabre@nondot.org> | 2003-04-30 22:19:10 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2003-04-30 22:19:10 +0000 |
| commit | 9244df60d3a9f61bf078071ec0ba98151fa94ddc (patch) | |
| tree | 20119c1faf8296e884471a78787da328f742db32 /llvm/lib/Transforms/Scalar | |
| parent | 5064581ca6c2ba509fd2a65f9f224a17753380b6 (diff) | |
| download | bcm5719-llvm-9244df60d3a9f61bf078071ec0ba98151fa94ddc.tar.gz bcm5719-llvm-9244df60d3a9f61bf078071ec0ba98151fa94ddc.zip | |
Fix constant folding of constexprs
llvm-svn: 5971
Diffstat (limited to 'llvm/lib/Transforms/Scalar')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/InstructionCombining.cpp | 9 |
1 files changed, 3 insertions, 6 deletions
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<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; } |

