Hi,<div><br></div><div>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).</div>
<div><br></div><div> - How does LLVM cope with builtin's that are target specific? Does the Target backend know of all these specialized instructions?</div><div> - 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)?</div>
<div> - 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? </div><div><br></div><div>I know these are probably questions born out of misunderstanding, but that's why I'm asking. It's important to know what LLVM could provide if I say were to always bypass the system C library for these "builtins".</div>
<div><br></div><div>Thanks!</div><div><br></div><div>Ruben</div>