diff options
author | Michael Gottesman <mgottesman@apple.com> | 2013-07-27 21:49:21 +0000 |
---|---|---|
committer | Michael Gottesman <mgottesman@apple.com> | 2013-07-27 21:49:21 +0000 |
commit | 30a90eb1a54284535036cbb20b914dd229e5fb07 (patch) | |
tree | 507823d6beb247577b9f1fd969c011684262ce0a /llvm/lib/Support/APFloat.cpp | |
parent | aae69c0a1da441b5cc4a014185f22e92515ba85f (diff) | |
download | bcm5719-llvm-30a90eb1a54284535036cbb20b914dd229e5fb07.tar.gz bcm5719-llvm-30a90eb1a54284535036cbb20b914dd229e5fb07.zip |
[APFloat] Move setting fcNormal in zeroSignificand() to calling code.
Zeroing the significand of a floating point number does not necessarily cause a
floating point number to become finite non zero. For instance, if one has a NaN,
zeroing the significand will cause it to become +/- infinity.
llvm-svn: 187313
Diffstat (limited to 'llvm/lib/Support/APFloat.cpp')
-rw-r--r-- | llvm/lib/Support/APFloat.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/lib/Support/APFloat.cpp b/llvm/lib/Support/APFloat.cpp index ce57442219c..bc8e1d0c25e 100644 --- a/llvm/lib/Support/APFloat.cpp +++ b/llvm/lib/Support/APFloat.cpp @@ -778,6 +778,7 @@ APFloat::bitwiseIsEqual(const APFloat &rhs) const { APFloat::APFloat(const fltSemantics &ourSemantics, integerPart value) { initialize(&ourSemantics); sign = 0; + category = fcNormal; zeroSignificand(); exponent = ourSemantics.precision - 1; significandParts()[0] = value; @@ -845,7 +846,6 @@ APFloat::significandParts() void APFloat::zeroSignificand() { - category = fcNormal; APInt::tcSet(significandParts(), 0, partCount()); } @@ -2301,9 +2301,9 @@ APFloat::convertFromHexadecimalString(StringRef s, roundingMode rounding_mode) { lostFraction lost_fraction = lfExactlyZero; + category = fcNormal; zeroSignificand(); exponent = 0; - category = fcNormal; integerPart *significand = significandParts(); unsigned partsCount = partCount(); @@ -2512,6 +2512,7 @@ APFloat::convertFromDecimalString(StringRef str, roundingMode rounding_mode) (D.normalizedExponent + 1) * 28738 <= 8651 * (semantics->minExponent - (int) semantics->precision)) { /* Underflow to zero and round. */ + category = fcNormal; zeroSignificand(); fs = normalize(rounding_mode, lfLessThanHalf); @@ -3398,6 +3399,7 @@ APFloat APFloat::getSmallestNormalized(const fltSemantics &Sem, bool Negative) { // exponent = 0..0 // significand = 10..0 + Val.category = fcNormal; Val.zeroSignificand(); Val.sign = Negative; Val.exponent = Sem.minExponent; |