[llvm-commits] [llvm] r49458 - /llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp
Chris Lattner
clattner at apple.com
Thu Apr 10 10:25:16 PDT 2008
On Apr 10, 2008, at 9:51 AM, Chris Lattner wrote:
> On Apr 10, 2008, at 9:47 AM, Duncan Sands wrote:
>> On Thursday 10 April 2008 18:21:24 Chris Lattner wrote:
>>> On Apr 10, 2008, at 4:25 AM, Duncan Sands wrote:
>>>>>>> + // x pow(x, 0.5) sqrt(x)
>>>>>>> + // ---------------------------------------------
>>>>>>> + // -0.0 +0.0 -0.0
>>>>>>> + // -inf +inf NaN
>>>>>>
>>>>>> looks like pow is broken. Is pow's behaviour documented
>>>>>> anywhere? On my machine the man page says:
>>>>>>
>>>>>> The pow() function can return the following error:
>>>>>>
>>>>>> EDOM The argument x is negative and y is not an integral
>>>>>> value. This would result in a complex num‐
>>>>>> ber.
>>>>>>
>>>
>>> -0.0 is negative, but it *is* an integral value, so EDOM doesn't
>>> apply.
>>
>> You are confusing x and y.
>
> Whoa, you're right. I'll ping my numeric guru and ask why. :)
His response:
I stand behind the claim that the behavior of the pow(x, 0.5) -> sqrt
substitution is incompatible with C99. Here are the exact citations:
From C99, Annex F (normative):
F.9.4.4 The pow functions
– pow(+-0, y) returns +0 for y > 0 and not an odd integer.
– pow(-inf, y) returns +inf for y > 0 and not an odd integer.
F.9.4.5 The sqrt functions
sqrt is fully specified as a basic arithmetic operation in IEC 60559
From IEC 60559 (IEEE 754-1985), section 5.2:
... the square root of -0 shall be -0.
Does that pin things down enough for you?
– Steve
More information about the llvm-commits
mailing list