X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FSupport%2FAPFloat.cpp;h=cc86e795e7927e6616b05b0441bd3a66f062a099;hb=e6be34a53ecbe8c2ff9f0793b13d847e94c0de91;hp=04e99149bb853a5d3c3205f7054678659a8502fd;hpb=b10abe1e8c19f60191dd7afa50f8c623e2b8f041;p=oota-llvm.git diff --git a/lib/Support/APFloat.cpp b/lib/Support/APFloat.cpp index 04e99149bb8..cc86e795e79 100644 --- a/lib/Support/APFloat.cpp +++ b/lib/Support/APFloat.cpp @@ -13,6 +13,7 @@ //===----------------------------------------------------------------------===// #include "llvm/ADT/APFloat.h" +#include "llvm/ADT/FoldingSet.h" #include #include #include "llvm/Support/MathExtras.h" @@ -691,6 +692,11 @@ APFloat::~APFloat() freeSignificand(); } +// Profile - This method 'profiles' an APFloat for use with FoldingSet. +void APFloat::Profile(FoldingSetNodeID& ID) const { + ID.Add(convertToAPInt()); +} + unsigned int APFloat::partCount() const { @@ -1712,6 +1718,8 @@ APFloat::convert(const fltSemantics &toSemantics, fs = normalize(rounding_mode, lostFraction); } else if (category == fcNaN) { int shift = toSemantics.precision - semantics->precision; + // Do this now so significandParts gets the right answer + semantics = &toSemantics; // No normalization here, just truncate if (shift>0) APInt::tcShiftLeft(significandParts(), newPartCount, shift); @@ -1721,7 +1729,6 @@ APFloat::convert(const fltSemantics &toSemantics, // does not give you back the same bits. This is dubious, and we // don't currently do it. You're really supposed to get // an invalid operation signal at runtime, but nobody does that. - semantics = &toSemantics; fs = opOK; } else { semantics = &toSemantics;