[llvm-commits] CVS: llvm/lib/VMCore/iOperators.cpp
Chris Lattner
lattner at cs.uiuc.edu
Mon Feb 2 14:22:34 PST 2004
Changes in directory llvm/lib/VMCore:
iOperators.cpp updated: 1.25 -> 1.26
---
Log message:
Floating point negates are -0.0 - X, not 0.0 - X
---
Diffs of the changes: (+13 -5)
Index: llvm/lib/VMCore/iOperators.cpp
diff -u llvm/lib/VMCore/iOperators.cpp:1.25 llvm/lib/VMCore/iOperators.cpp:1.26
--- llvm/lib/VMCore/iOperators.cpp:1.25 Thu Nov 20 11:45:12 2003
+++ llvm/lib/VMCore/iOperators.cpp Mon Feb 2 14:21:29 2004
@@ -78,9 +78,14 @@
BinaryOperator *BinaryOperator::createNeg(Value *Op, const std::string &Name,
Instruction *InsertBefore) {
- 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::createNot(Value *Op, const std::string &Name,
@@ -98,8 +103,11 @@
bool BinaryOperator::isNeg(const Value *V) {
if (const BinaryOperator *Bop = dyn_cast<BinaryOperator>(V))
- return Bop->getOpcode() == Instruction::Sub &&
- Bop->getOperand(0) == Constant::getNullValue(Bop->getType());
+ if (Bop->getOpcode() == Instruction::Sub)
+ if (!V->getType()->isFloatingPoint())
+ return Bop->getOperand(0) == Constant::getNullValue(Bop->getType());
+ else
+ return Bop->getOperand(0) == ConstantFP::get(Bop->getType(), -0.0);
return false;
}
More information about the llvm-commits
mailing list