summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-02-02 20:21:29 +0000
committerChris Lattner <sabre@nondot.org>2004-02-02 20:21:29 +0000
commitbcade4b8e6190e86942fe1c05c4c837fe9f7332f (patch)
tree613b6f72ada1606410122f2e7ef4c03e0ce60a13 /llvm/lib
parentc2f0aa58dfff6182677f70d26ec85634ae045e3d (diff)
downloadbcm5719-llvm-bcade4b8e6190e86942fe1c05c4c837fe9f7332f.tar.gz
bcm5719-llvm-bcade4b8e6190e86942fe1c05c4c837fe9f7332f.zip
Floating point negates are -0.0 - X, not 0.0 - X
llvm-svn: 11084
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/VMCore/iOperators.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/llvm/lib/VMCore/iOperators.cpp b/llvm/lib/VMCore/iOperators.cpp
index 9cd7612fcb2..977849e22cc 100644
--- a/llvm/lib/VMCore/iOperators.cpp
+++ b/llvm/lib/VMCore/iOperators.cpp
@@ -78,9 +78,14 @@ BinaryOperator *BinaryOperator::create(BinaryOps Op, Value *S1, Value *S2,
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 @@ static inline bool isConstantAllOnes(const Value *V) {
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;
}
OpenPOWER on IntegriCloud