efriedma added a comment.

The gcc documentation says "GCC includes built-in versions of many of the 
functions in the standard C library. These functions come in two forms: one 
whose names start with the `__builtin_` prefix, and the other without. Both 
forms have the same type (including prototype), the same address (when their 
address is taken), and the same meaning as the C library functions".  And gcc 
specifically preserves the stated semantics.  Given that, I'm not sure it makes 
sense for us to try to redefine `__builtin_sqrt()` just because it's convenient.

Note that this reasoning only applies if the user hasn't specified any 
fast-math flags; under -ffinite-math-only, we can assume the result isn't a 
NaN, and therefore we can use `llvm.sqrt.*`. (The definition of `llvm.sqrt.*` 
changed in https://reviews.llvm.org/D28797; I don't think we ever updated clang 
to take advantage of this).

If we really need a name for the never-sets-errno sqrt, we should probably use 
a different name, e.g. `__builtin_ieee_sqrt()`.


https://reviews.llvm.org/D39204



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to