[LLVMdev] sqrt

Dale Johannesen dalej at apple.com
Thu Jan 7 16:14:32 PST 2010


On Jan 7, 2010, at 4:04 PMPST, Chris Lattner wrote:
> On Jan 7, 2010, at 3:53 PM, Robert A. Zeh wrote:
> On Jan 7, 2010, at 11:48 AM, Chris Lattner <clattner at apple.com> wrote:
>>
>>> There is a fundamental difference between sqrt() and llvm.sqrt: the
>>> former is defined on negative values and sets errno (on linux).  The
>>> later is undefined.  Both work well for their stated purpose,
>>> llvm.sqrt should not be slower than sqrt even on linux.  Both
>>> llvm.sqrt and sqrt could be much better on linux, but noone seems
>>> compelled to do the work.
>>>
>>> -Chris
>>
>> What exactly is the work for llvm.sqrt on Linux?
>
> Ah sorry, llvm.sqrt works fine on linux.  The issue is that a raw  
> call to sqrt() in a C program doesn't typically compile to llvm.sqrt  
> on linux, because it sets errno.  This can be controlled with -fmath- 
> errno.


It is more than errno.   sqrt() should't compile to llvm.sqrt on any  
platform that uses IEEE754 math, because IEEE sqrt() is well defined  
on negative arguments and llvm.sqrt isn't.  There are currently no  
command line arguments to override this.




More information about the llvm-dev mailing list