<div class="gmail_quote">2012/1/20 Jean-Daniel Dupas <span dir="ltr"><<a href="mailto:devlists@shadowlab.org">devlists@shadowlab.org</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Le 20 janv. 2012 à 14:38, Ruben Van Boxem a écrit :<br>
<div class="im"><br>
> Hi,<br>
><br>
> Lately, I have been wondering how a compiler like GCC or Clang implements builtin functions like sqrt, sin, and also more bit-specific things like bcmp and ffs. Originially, these were all deferred to the C library where they might still have a "backup implementation", but I don't understand why a compiler would choose the non-builtin version, as it should know its version is faster (or that's the way it should be at least).<br>

><br>
>  - How does LLVM cope with builtin's that are target specific? Does the Target backend know of all these specialized instructions?<br>
>  - Does LLVM have a representation for all C library functions that have or might have a future hardware implementation? Or is this mostly handled by the whole toolchain (Clang adds target-specific info into the LLVM bitcode which is forced to produce the asm instruction if the target supports it)?<br>

>  - Is it possible to code a sqrt or sin in LLVM bitcode that will use the hardware instruction if it's compiled for a certain target?<br>
<br>
<br>
</div>See the LLVM language reference for the list of supported intrinsics: <a href="http://llvm.org/docs/LangRef.html#int_libc" target="_blank">http://llvm.org/docs/LangRef.html#int_libc</a></blockquote><div><br></div><div>
Thanks for that. I still wonder what happens to stuff like log1p, which translates to a machine instruction on x86. Can the LLVM backend discover that this operation is called for, and use the native instruction in this case?</div>
<div><br></div><div>Thanks,</div><div><br></div><div>Ruben</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<span class="HOEnZb"><font color="#888888"><br>
-- Jean-Daniel<br>
<br>
<br>
<br>
<br>
</font></span></blockquote></div><br>