[llvm-commits] [llvm] r141816 - in /llvm/trunk: lib/Support/APFloat.cpp unittests/ADT/APFloatTest.cpp
Eli Friedman
eli.friedman at gmail.com
Wed Oct 12 16:16:56 PDT 2011
On Wed, Oct 12, 2011 at 4:05 PM, Francois Pichet <pichet2000 at gmail.com> wrote:
> On Wed, Oct 12, 2011 at 5:51 PM, Eli Friedman <eli.friedman at gmail.com> wrote:
>> Author: efriedma
>> Date: Wed Oct 12 16:51:36 2011
>> New Revision: 141816
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=141816&view=rev
>> Log:
>> Fix APFloat::getLargest so that it actually returns the correct value. Found by accident while reviewing a patch to nearby code.
>>
>>
>> Modified:
>> llvm/trunk/lib/Support/APFloat.cpp
>> llvm/trunk/unittests/ADT/APFloatTest.cpp
>>
>> Modified: llvm/trunk/lib/Support/APFloat.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/APFloat.cpp?rev=141816&r1=141815&r2=141816&view=diff
>> ==============================================================================
>> --- llvm/trunk/lib/Support/APFloat.cpp (original)
>> +++ llvm/trunk/lib/Support/APFloat.cpp Wed Oct 12 16:51:36 2011
>> @@ -3243,8 +3243,9 @@
>> significand[i] = ~((integerPart) 0);
>>
>> // ...and then clear the top bits for internal consistency.
>> - significand[N-1] &=
>> - (((integerPart) 1) << ((Sem.precision % integerPartWidth) - 1)) - 1;
>> + if (Sem.precision % integerPartWidth != 0)
>> + significand[N-1] &=
>> + (((integerPart) 1) << (Sem.precision % integerPartWidth)) - 1;
>>
>> return Val;
>> }
>>
>> Modified: llvm/trunk/unittests/ADT/APFloatTest.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/APFloatTest.cpp?rev=141816&r1=141815&r2=141816&view=diff
>> ==============================================================================
>> --- llvm/trunk/unittests/ADT/APFloatTest.cpp (original)
>> +++ llvm/trunk/unittests/ADT/APFloatTest.cpp Wed Oct 12 16:51:36 2011
>> @@ -648,4 +648,9 @@
>> EXPECT_FALSE(APFloat(1.40129846e-45f).getExactInverse(0));
>> }
>>
>> +TEST(APFloatTest, getLargest) {
>> + EXPECT_EQ(3.40282347e+38f, APFloat::getLargest(APFloat::IEEEsingle).convertToFloat());
>> + EXPECT_EQ(1.7976931348623157e+308, APFloat::getLargest(APFloat::IEEEdouble).convertToDouble());
>> +}
>
> On MSVC:
>
> 1>ADT\APFloatTest.cpp(652): error C2177: constant too big
> 1>ADT\APFloatTest.cpp(652): error C2177: constant too big
Try r141831?
-Eli
More information about the llvm-commits
mailing list