- return new BinaryOperator(Instruction::Sub,
- Constant::getNullValue(Op->getType()), Op,
- Op->getType(), Name, InsertBefore);
+ if (!Op->getType()->isFloatingPoint())
+ return new BinaryOperator(Instruction::Sub,
+ Constant::getNullValue(Op->getType()), Op,
+ Op->getType(), Name, InsertBefore);
+ else
+ return new BinaryOperator(Instruction::Sub,
+ ConstantFP::get(Op->getType(), -0.0), Op,
+ Op->getType(), Name, InsertBefore);
+}
+
+BinaryOperator *BinaryOperator::createNeg(Value *Op, const std::string &Name,
+ BasicBlock *InsertAtEnd) {
+ if (!Op->getType()->isFloatingPoint())
+ return new BinaryOperator(Instruction::Sub,
+ Constant::getNullValue(Op->getType()), Op,
+ Op->getType(), Name, InsertAtEnd);
+ else
+ return new BinaryOperator(Instruction::Sub,
+ ConstantFP::get(Op->getType(), -0.0), Op,
+ Op->getType(), Name, InsertAtEnd);