summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/ConstantFolding.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2010-09-17 20:06:27 +0000
committerDan Gohman <gohman@apple.com>2010-09-17 20:06:27 +0000
commitb48f904602ab60ea21f3c839e50c274b8a022beb (patch)
treec19f526d7edd6c932e7395fdb8755985f191257f /llvm/lib/Analysis/ConstantFolding.cpp
parent1287f4f3b84ef111a8742691d64e0d7cb3a0485d (diff)
downloadbcm5719-llvm-b48f904602ab60ea21f3c839e50c274b8a022beb.tar.gz
bcm5719-llvm-b48f904602ab60ea21f3c839e50c274b8a022beb.zip
Attempt to support platforms which don't have fenv.h.
llvm-svn: 114196
Diffstat (limited to 'llvm/lib/Analysis/ConstantFolding.cpp')
-rw-r--r--llvm/lib/Analysis/ConstantFolding.cpp19
1 files changed, 7 insertions, 12 deletions
diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp
index 69581ba5ecd..c015231e1ba 100644
--- a/llvm/lib/Analysis/ConstantFolding.cpp
+++ b/llvm/lib/Analysis/ConstantFolding.cpp
@@ -30,6 +30,7 @@
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/GetElementPtrTypeIterator.h"
#include "llvm/Support/MathExtras.h"
+#include "llvm/System/FEnv.h"
#include <cerrno>
#include <cmath>
#include <fenv.h>
@@ -1040,13 +1041,10 @@ llvm::canConstantFoldCallTo(const Function *F) {
static Constant *ConstantFoldFP(double (*NativeFP)(double), double V,
const Type *Ty) {
- feclearexcept(FE_ALL_EXCEPT);
- errno = 0;
+ sys::llvm_fenv_clearexcept();
V = NativeFP(V);
- if (errno != 0 ||
- fetestexcept(FE_DIVBYZERO | FE_UNDERFLOW | FE_OVERFLOW | FE_INVALID)) {
- feclearexcept(FE_ALL_EXCEPT);
- errno = 0;
+ if (sys::llvm_fenv_testexcept()) {
+ sys::llvm_fenv_clearexcept();
return 0;
}
@@ -1060,13 +1058,10 @@ static Constant *ConstantFoldFP(double (*NativeFP)(double), double V,
static Constant *ConstantFoldBinaryFP(double (*NativeFP)(double, double),
double V, double W, const Type *Ty) {
- feclearexcept(FE_ALL_EXCEPT);
- errno = 0;
+ sys::llvm_fenv_clearexcept();
V = NativeFP(V, W);
- if (errno != 0 ||
- fetestexcept(FE_DIVBYZERO | FE_UNDERFLOW | FE_OVERFLOW | FE_INVALID)) {
- feclearexcept(FE_ALL_EXCEPT);
- errno = 0;
+ if (sys::llvm_fenv_testexcept()) {
+ sys::llvm_fenv_clearexcept();
return 0;
}
OpenPOWER on IntegriCloud