Handle -0.0 correctly
authorChris Lattner <sabre@nondot.org>
Mon, 29 Mar 2004 19:51:24 +0000 (19:51 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 29 Mar 2004 19:51:24 +0000 (19:51 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12530 91177308-0d34-0410-b5e6-96231b3b80d8

lib/VMCore/Constants.cpp

index 21f19b98b11191703f695a48b9189693017d4974..e1b0f18dc325fc552cb36c26e5251c878c69aed7 100644 (file)
@@ -313,7 +313,10 @@ ConstantExpr::ConstantExpr(Constant *C, const std::vector<Constant*> &IdxList,
 /// specify the full Instruction::OPCODE identifier.
 ///
 Constant *ConstantExpr::getNeg(Constant *C) {
-  return get(Instruction::Sub, getNullValue(C->getType()), C);
+  if (!C->getType()->isFloatingPoint())
+    return get(Instruction::Sub, getNullValue(C->getType()), C);
+  else
+    return get(Instruction::Sub, ConstantFP::get(C->getType(), -0.0), C);
 }
 Constant *ConstantExpr::getNot(Constant *C) {
   assert(isa<ConstantIntegral>(C) && "Cannot NOT a nonintegral type!");