[llvm-commits] CVS: llvm/lib/VMCore/ConstantFolding.cpp
Jeff Cohen
jeffc at jolt-lang.org
Mon May 2 20:13:12 PDT 2005
Changes in directory llvm/lib/VMCore:
ConstantFolding.cpp updated: 1.75 -> 1.76
---
Log message:
Use ANSI-approved way of getting the value infinity (otherwise VC++ won't compile it)
---
Diffs of the changes: (+4 -3)
ConstantFolding.cpp | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
Index: llvm/lib/VMCore/ConstantFolding.cpp
diff -u llvm/lib/VMCore/ConstantFolding.cpp:1.75 llvm/lib/VMCore/ConstantFolding.cpp:1.76
--- llvm/lib/VMCore/ConstantFolding.cpp:1.75 Mon May 2 16:25:47 2005
+++ llvm/lib/VMCore/ConstantFolding.cpp Mon May 2 22:13:01 2005
@@ -24,6 +24,7 @@
#include "llvm/DerivedTypes.h"
#include "llvm/Function.h"
#include "llvm/Support/GetElementPtrTypeIterator.h"
+#include <limits>
#include <cmath>
using namespace llvm;
@@ -471,9 +472,9 @@
return ConstantClass::get(*Ty, Result);
}
static Constant *Div(const ConstantClass *V1, const ConstantClass *V2) {
- if (V2->isExactlyValue(0.0)) return ConstantClass::get(*Ty, INFINITY);
- if (V2->isExactlyValue(-0.0)) return ConstantClass::get(*Ty, -INFINITY);
- if (V2->isNullValue()) return 0;
+ BuiltinType inf = std::numeric_limits<BuiltinType>::infinity();
+ if (V2->isExactlyValue(0.0)) return ConstantClass::get(*Ty, inf);
+ if (V2->isExactlyValue(-0.0)) return ConstantClass::get(*Ty, -inf);
BuiltinType R = (BuiltinType)V1->getValue() / (BuiltinType)V2->getValue();
return ConstantClass::get(*Ty, R);
}
More information about the llvm-commits
mailing list