[llvm] r185095 - [APFloat] Removed APFloat constructor which initialized to either zero/NaN but allowed you to arbitrarily set the category of the float.

Michael Gottesman mgottesman at apple.com
Thu Jun 27 13:43:01 PDT 2013


This was causing failures on the mips/ppc bots on an x86 file check test which did not occur on the x86 bots = /.

I reverted while I am investigating.

Michael

On Jun 27, 2013, at 12:50 PM, Michael Gottesman <mgottesman at apple.com> wrote:

> Author: mgottesman
> Date: Thu Jun 27 14:50:52 2013
> New Revision: 185095
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=185095&view=rev
> Log:
> [APFloat] Removed APFloat constructor which initialized to either zero/NaN but allowed you to arbitrarily set the category of the float.
> 
> The category which an APFloat belongs to should be dependent on the
> actual value that the APFloat has, not be arbitrarily passed in by the
> user. This will prevent inconsistency bugs where the category and the
> actual value in APFloat differ.
> 
> I also fixed up all of the references to this constructor (which were
> only in LLVM).
> 
> Modified:
>    llvm/trunk/include/llvm/ADT/APFloat.h
>    llvm/trunk/lib/Support/APFloat.cpp
>    llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
> 
> Modified: llvm/trunk/include/llvm/ADT/APFloat.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/APFloat.h?rev=185095&r1=185094&r2=185095&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/ADT/APFloat.h (original)
> +++ llvm/trunk/include/llvm/ADT/APFloat.h Thu Jun 27 14:50:52 2013
> @@ -191,7 +191,6 @@ public:
>   APFloat(const fltSemantics &); // Default construct to 0.0
>   APFloat(const fltSemantics &, StringRef);
>   APFloat(const fltSemantics &, integerPart);
> -  APFloat(const fltSemantics &, fltCategory, bool negative);
>   APFloat(const fltSemantics &, uninitializedTag);
>   APFloat(const fltSemantics &, const APInt &);
>   explicit APFloat(double d);
> 
> Modified: llvm/trunk/lib/Support/APFloat.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/APFloat.cpp?rev=185095&r1=185094&r2=185095&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Support/APFloat.cpp (original)
> +++ llvm/trunk/lib/Support/APFloat.cpp Thu Jun 27 14:50:52 2013
> @@ -795,17 +795,6 @@ APFloat::APFloat(const fltSemantics &our
>   initialize(&ourSemantics);
> }
> 
> -APFloat::APFloat(const fltSemantics &ourSemantics,
> -                 fltCategory ourCategory, bool negative) {
> -  initialize(&ourSemantics);
> -  category = ourCategory;
> -  sign = negative;
> -  if (isFiniteNonZero())
> -    category = fcZero;
> -  else if (ourCategory == fcNaN)
> -    makeNaN();
> -}
> -
> APFloat::APFloat(const fltSemantics &ourSemantics, StringRef text) {
>   initialize(&ourSemantics);
>   convertFromString(text, rmNearestTiesToEven);
> @@ -2406,8 +2395,8 @@ APFloat::roundSignificandWithExponent(co
>     excessPrecision = calcSemantics.precision - semantics->precision;
>     truncatedBits = excessPrecision;
> 
> -    APFloat decSig(calcSemantics, fcZero, sign);
> -    APFloat pow5(calcSemantics, fcZero, false);
> +    APFloat decSig = APFloat::getZero(calcSemantics, sign);
> +    APFloat pow5(calcSemantics);
> 
>     sigStatus = decSig.convertFromUnsignedParts(decSigParts, sigPartCount,
>                                                 rmNearestTiesToEven);
> @@ -3388,15 +3377,16 @@ APFloat APFloat::getSmallest(const fltSe
> }
> 
> APFloat APFloat::getSmallestNormalized(const fltSemantics &Sem, bool Negative) {
> -  APFloat Val(Sem, fcNormal, Negative);
> +  APFloat Val(Sem, uninitialized);
> 
>   // We want (in interchange format):
>   //   sign = {Negative}
>   //   exponent = 0..0
>   //   significand = 10..0
> 
> -  Val.exponent = Sem.minExponent;
>   Val.zeroSignificand();
> +  Val.sign = Negative;
> +  Val.exponent = Sem.minExponent;
>   Val.significandParts()[partCountForBits(Sem.precision)-1] |=
>     (((integerPart) 1) << ((Sem.precision - 1) % integerPartWidth));
> 
> 
> Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp?rev=185095&r1=185094&r2=185095&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp (original)
> +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Thu Jun 27 14:50:52 2013
> @@ -2888,7 +2888,7 @@ Instruction *InstCombiner::FoldFCmp_IntT
>   if (!LHSUnsigned) {
>     // If the RHS value is > SignedMax, fold the comparison.  This handles +INF
>     // and large values.
> -    APFloat SMax(RHS.getSemantics(), APFloat::fcZero, false);
> +    APFloat SMax(RHS.getSemantics());
>     SMax.convertFromAPInt(APInt::getSignedMaxValue(IntWidth), true,
>                           APFloat::rmNearestTiesToEven);
>     if (SMax.compare(RHS) == APFloat::cmpLessThan) {  // smax < 13123.0
> @@ -2900,7 +2900,7 @@ Instruction *InstCombiner::FoldFCmp_IntT
>   } else {
>     // If the RHS value is > UnsignedMax, fold the comparison. This handles
>     // +INF and large values.
> -    APFloat UMax(RHS.getSemantics(), APFloat::fcZero, false);
> +    APFloat UMax(RHS.getSemantics());
>     UMax.convertFromAPInt(APInt::getMaxValue(IntWidth), false,
>                           APFloat::rmNearestTiesToEven);
>     if (UMax.compare(RHS) == APFloat::cmpLessThan) {  // umax < 13123.0
> @@ -2913,7 +2913,7 @@ Instruction *InstCombiner::FoldFCmp_IntT
> 
>   if (!LHSUnsigned) {
>     // See if the RHS value is < SignedMin.
> -    APFloat SMin(RHS.getSemantics(), APFloat::fcZero, false);
> +    APFloat SMin(RHS.getSemantics());
>     SMin.convertFromAPInt(APInt::getSignedMinValue(IntWidth), true,
>                           APFloat::rmNearestTiesToEven);
>     if (SMin.compare(RHS) == APFloat::cmpGreaterThan) { // smin > 12312.0
> @@ -2924,7 +2924,7 @@ Instruction *InstCombiner::FoldFCmp_IntT
>     }
>   } else {
>     // See if the RHS value is < UnsignedMin.
> -    APFloat SMin(RHS.getSemantics(), APFloat::fcZero, false);
> +    APFloat SMin(RHS.getSemantics());
>     SMin.convertFromAPInt(APInt::getMinValue(IntWidth), true,
>                           APFloat::rmNearestTiesToEven);
>     if (SMin.compare(RHS) == APFloat::cmpGreaterThan) { // umin > 12312.0
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130627/8b074d22/attachment.html>


More information about the llvm-commits mailing list