[LLVMdev] Generating Floating point constants
John McCall
rjmccall at apple.com
Thu Jun 3 10:47:03 PDT 2010
On Jun 3, 2010, at 7:05 AM, Stéphane Letz wrote:
>
> Le 3 juin 2010 à 16:00, Martin Guy a écrit :
>
>> [off list]
>>
>>> 0.8f get converted in 0x3FE99999A0000000 by LLVM
>>
>> single precision
>>
>>> http://babbage.cs.qc.edu/IEEE-754/Decimal.html gives:
>>>
>>> 0x3FE999999999999A instead and this value cannot be read back by "llc"...
>>
>> double precision
>>
>> M
>
>
> Well
>
> For float 0.8 :
>
> http://babbage.cs.qc.edu/IEEE-754/Decimal.html
>
> 3F4CCCCD for Single precision (32 bits):
>
> 3FE999999999999A for Double precision (64 bits):
>
> Still different compared to LLVM...
>
> Any idea?
LLVM serializes and deserializes float constants in double precision. I don't know why.
0x3F4CCCCD = (sign=0, exp=01111110 (-1), significand=0x99999A)
0x3FE99999A0000000 = (sign = 0, exp=01111111110 (-1), significand=0x99999A0000000)
If you try to deserialize 0x3FE999999999999A as a float, it loses a lot of precision, which I presume is why llc complains.
John.
More information about the llvm-dev
mailing list