Don't treat rint as setting errno
authorRichard Sandiford <richard.sandiford@arm.com>
Sat, 7 Nov 2015 10:00:31 +0000 (10:00 +0000)
committerRichard Sandiford <rsandifo@gcc.gnu.org>
Sat, 7 Nov 2015 10:00:31 +0000 (10:00 +0000)
builtins.def says that rint sets errno, but it looks like this might
be a mistake.  C99 says that rint doesn't set errno and the builtins.c
expansion code doesn't try to keep errno up to date.

Perhaps this was because earlier versions of POSIX said that
rint sets errno on overflow:

        http://pubs.opengroup.org/onlinepubs/009695399/functions/rintf.html

However, this is another instance of the observation that "rounding
functions could never overflow" (because anything using exponents
that large is already integral).  The page above also says that
differences with C99 are unintentional and the ERANGE clause has
been removed from later versions of POSIX:

        http://pubs.opengroup.org/onlinepubs/9699919799/functions/rint.html

Also, the version of POSIX that lists ERANGE for rint does the same
for nearbyint:

        http://pubs.opengroup.org/onlinepubs/009695399/functions/nearbyintf.html

and we already treat nearbyint as not setting errno.  This too has been
clarified in later versions of POSIX:

        http://pubs.opengroup.org/onlinepubs/9699919799/functions/nearbyint.html

Tested on x86_64-linux-gnu, aarch64-linux-gnu and arm-linux-gnueabi.

gcc/
* builtins.def (BUILTIN_RINT, BUILTIN_RINTF, BUILTIN_RINTL): Use
ATTR_MATHFN_FPROUNDING rather than ATTR_MATHFN_FPROUNDING_ERRNO.

From-SVN: r229918

gcc/ChangeLog
gcc/builtins.def

index 6e7ab8e048fc03547c5e62e68ceea3aa85fcc883..41ed6307a37204d8243d31a6294d02b3c6e5b3ba 100644 (file)
@@ -1,3 +1,8 @@
+2015-11-07  Richard Sandiford  <richard.sandiford@arm.com>
+
+       * builtins.def (BUILTIN_RINT, BUILTIN_RINTF, BUILTIN_RINTL): Use
+       ATTR_MATHFN_FPROUNDING rather than ATTR_MATHFN_FPROUNDING_ERRNO.
+
 2015-11-07  Richard Sandiford  <richard.sandiford@arm.com>
 
        * tree-call-cdce.c (shrink_wrap_one_built_in_call): Try to update
index 886b45ccec34c0ddcfc02d3f328c171efae38c90..076da406e1febeea6291fe51e67436fd3594ae45 100644 (file)
@@ -475,9 +475,9 @@ DEF_C99_BUILTIN        (BUILT_IN_REMAINDERL, "remainderl", BT_FN_LONGDOUBLE_LONG
 DEF_C99_BUILTIN        (BUILT_IN_REMQUO, "remquo", BT_FN_DOUBLE_DOUBLE_DOUBLE_INTPTR, ATTR_MATHFN_FPROUNDING_STORE)
 DEF_C99_BUILTIN        (BUILT_IN_REMQUOF, "remquof", BT_FN_FLOAT_FLOAT_FLOAT_INTPTR, ATTR_MATHFN_FPROUNDING_STORE)
 DEF_C99_BUILTIN        (BUILT_IN_REMQUOL, "remquol", BT_FN_LONGDOUBLE_LONGDOUBLE_LONGDOUBLE_INTPTR, ATTR_MATHFN_FPROUNDING_STORE)
-DEF_C99_BUILTIN        (BUILT_IN_RINT, "rint", BT_FN_DOUBLE_DOUBLE, ATTR_MATHFN_FPROUNDING_ERRNO)
-DEF_C99_BUILTIN        (BUILT_IN_RINTF, "rintf", BT_FN_FLOAT_FLOAT, ATTR_MATHFN_FPROUNDING_ERRNO)
-DEF_C99_BUILTIN        (BUILT_IN_RINTL, "rintl", BT_FN_LONGDOUBLE_LONGDOUBLE, ATTR_MATHFN_FPROUNDING_ERRNO)
+DEF_C99_BUILTIN        (BUILT_IN_RINT, "rint", BT_FN_DOUBLE_DOUBLE, ATTR_MATHFN_FPROUNDING)
+DEF_C99_BUILTIN        (BUILT_IN_RINTF, "rintf", BT_FN_FLOAT_FLOAT, ATTR_MATHFN_FPROUNDING)
+DEF_C99_BUILTIN        (BUILT_IN_RINTL, "rintl", BT_FN_LONGDOUBLE_LONGDOUBLE, ATTR_MATHFN_FPROUNDING)
 DEF_C99_BUILTIN        (BUILT_IN_ROUND, "round", BT_FN_DOUBLE_DOUBLE, ATTR_CONST_NOTHROW_LEAF_LIST)
 DEF_C99_BUILTIN        (BUILT_IN_ROUNDF, "roundf", BT_FN_FLOAT_FLOAT, ATTR_CONST_NOTHROW_LEAF_LIST)
 DEF_C99_BUILTIN        (BUILT_IN_ROUNDL, "roundl", BT_FN_LONGDOUBLE_LONGDOUBLE, ATTR_CONST_NOTHROW_LEAF_LIST)