[LLVMdev] [RFC] How to fix sqrt vs llvm.sqrt optimization asymmetry

Chris Lattner clattner at apple.com
Mon Nov 11 22:23:59 PST 2013


On Nov 11, 2013, at 9:30 PM, Hal Finkel <hfinkel at anl.gov> wrote:

> ----- Original Message -----
>> Hi Hal, all.
>> 
>> I'm not sure why llvm.sqrt is 'special'.  Maybe because there is a
>> SSE
>> packed sqrt instruction (SQRTPS) but not e.g. a packed sin
>> instruction
>> AFAIK.
> 
> This seems relevant: http://lists.cs.uiuc.edu/pipermail/llvmdev/2007-August/010248.html
> 
> Chris, et al., does the decision on how to treat sqrt predate our current way of handling errno?

The intention of llvm.sqrt is that it is the same as sqrt(), but doesn't affect errno.  If it helps, I think it would be completely reasonable to change this in langref.html:

"Unlike sqrt in libm, however, llvm.sqrt has undefined behavior for ..."

to "... produces an undefined value", with a link back to ##undefined-values.

Transformations that apply to sqrt() should generally apply to llvm.sqrt as well.

-Chris



More information about the llvm-dev mailing list