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

Tim Northover t.p.northover at gmail.com
Mon Nov 11 22:39:58 PST 2013


> 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.

I don't think that helps the front-end writers significantly (they'll
still have to check the input to get a sensible total function).

CodeGen and backends can already do whatever they like with the
current semantics, but it looks like we could tighten those up to "...
produces a NaN" without inconveniencing any targets I've found. This
also matches at least OSX and Linux man-pages about the sqrt function.

Cheers.

Tim.



More information about the llvm-dev mailing list