This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH]: Use -frounding-math for builtins that care about rounding


Long ago, we setup builtin attributes on all the c math functions.  One of
the things we had to be mindful of was whether the math function was
affected by rounding mode.  If it was, we used -funsafe-math-optimizations
as a proxy to determine whether the rounding mode mattered to the user.
http://gcc.gnu.org/ml/gcc-patches/2002-07/msg00232.html

Some time after that, we created a specific flag -frounding-math for this.
http://gcc.gnu.org/ml/gcc-patches/2003-09/msg00104.html

The patch below changes the macro in builtins.def to honor that more
specific flag instead of -funsafe-math-optimizations.

Tested on sparc-sun-solaris2.10, no regressions.

Okay for mainline?

		Thanks,
		--Kaveh


2007-03-02  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* builtins.def (ATTR_MATHFN_FPROUNDING): Rely on
	flag_rounding_math, not flag_unsafe_math_optimizations.

diff -rup orig/egcc-SVN20070301/gcc/builtins.def egcc-SVN20070301/gcc/builtins.def
--- orig/egcc-SVN20070301/gcc/builtins.def	2007-02-10 20:03:45.000000000 -0500
+++ egcc-SVN20070301/gcc/builtins.def	2007-03-02 14:25:17.736917778 -0500
@@ -150,13 +150,13 @@ Software Foundation, 51 Franklin Street,
 	ATTR_NOTHROW_LIST : ATTR_CONST_NOTHROW_LIST)

 /* Define an attribute list for math functions that are normally
-   "pure" but if flag_unsafe_math_optimizations is set they are
-   instead "const".  This distinction accounts for the fact that some
-   math functions check the rounding mode which is akin to examining
-   global memory.  In "unsafe" mode we can be less careful.  */
+   "const" but if flag_rounding_math is set they are instead "pure".
+   This distinction accounts for the fact that some math functions
+   check the rounding mode which is akin to examining global
+   memory.  */
 #undef ATTR_MATHFN_FPROUNDING
-#define ATTR_MATHFN_FPROUNDING (flag_unsafe_math_optimizations ? \
-	ATTR_CONST_NOTHROW_LIST : ATTR_PURE_NOTHROW_NOVOPS_LIST)
+#define ATTR_MATHFN_FPROUNDING (flag_rounding_math ? \
+	ATTR_PURE_NOTHROW_NOVOPS_LIST : ATTR_CONST_NOTHROW_LIST)

 /* Define an attribute list for math functions that are normally
    "impure" because some of them may write into global memory for


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]