[PATCH] D39611: [CodeGen] make cbrt and fma constant (never set errno); document complex calls as always constant
Sanjay Patel via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 3 12:11:16 PDT 2017
spatel created this revision.
Herald added a subscriber: mcrosier.
These are 3 errno-related diffs raised in D39841.
1. Cube root
We're going to dismiss POSIX language like this:
"On successful completion, cbrt() returns the cube root of x. If x is NaN, cbrt() returns NaN and errno may be set to [EDOM]. "
http://pubs.opengroup.org/onlinepubs/7908799/xsh/cbrt.html
And favor an interpretation based on the C standard that says:
"Functions with a NaN argument return a NaN result and raise no floating-point exception, except where stated otherwise."
2. Floating multiply-add
The C standard is silent?
http://pubs.opengroup.org/onlinepubs/9699919799/functions/fma.html - clearly says "...then errno shall be set..."
but:
https://linux.die.net/man/3/fma - "These functions do not set errno."
Let's opt for the - hopefully common - implementation where errno is not set. Note that there's no test change because as noted in the earlier discussion, we're ignoring the const attr in CodeGenFunction::EmitBuiltinExpr(). I'll look at what needs fixing in that function next.
3. Complex
This is came up specifically for 'carg', but I'm hoping we can use 1 justification for the whole lib.
The POSIX docs all have language like this for complex calls:
"No errors are defined."
http://pubs.opengroup.org/onlinepubs/9699919799/functions/ccos.html
The lack of errno handling is allowed by the inclusion of "optionally" in the C standard definitions of all of the complex ops?
"csqrt(x + iNaN) returns NaN + iNaN and optionally raises the ‘‘invalid’’ floating-point exception, for finite x"
https://reviews.llvm.org/D39611
Files:
include/clang/Basic/Builtins.def
test/CodeGen/builtin-errno.c
test/CodeGen/libcalls-errno.c
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39611.121521.patch
Type: text/x-patch
Size: 5464 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171103/d4a9c811/attachment.bin>
More information about the cfe-commits
mailing list