[PATCH]: PR middle-end/29335 handle builtin fdim

Kaveh R. GHAZI ghazi@caip.rutgers.edu
Fri Jan 19 14:03:00 GMT 2007


This is one I missed in my basic MPFR integration.  Bootstrapped on
sparc-sun-solaris2.10.  At the moment, I'm having libjava build failures
on solaris so this was done with --disable-libgcj.  But I enable
non-default languages treelang and objc++, so it cancels out a bit. :-)
Also the libstdc++ libiconv problems persist.  With those caveats, no
regressions occured.

Okay for mainline?

		Thanks,
		--Kaveh


2007-01-17  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	PR middle-end/29335
	* builtins.c (fold_builtin_1): Handle builtin fdim.

testsuite:
	* gcc.dg/torture/builtin-math-3.c: Test fdim.

diff -rup orig/egcc-SVN20070115/gcc/builtins.c egcc-SVN20070115/gcc/builtins.c
--- orig/egcc-SVN20070115/gcc/builtins.c	2007-01-11 20:01:34.000000000 -0500
+++ egcc-SVN20070115/gcc/builtins.c	2007-01-17 01:52:58.581372651 -0500
@@ -9452,6 +9452,13 @@ fold_builtin_1 (tree fndecl, tree arglis
 			     type, mpfr_atan2);
     break;

+    CASE_FLT_FN (BUILT_IN_FDIM):
+      if (validate_arglist (arglist, REAL_TYPE, REAL_TYPE, VOID_TYPE))
+	return do_mpfr_arg2 (TREE_VALUE (arglist),
+			     TREE_VALUE (TREE_CHAIN (arglist)),
+			     type, mpfr_dim);
+    break;
+
     CASE_FLT_FN (BUILT_IN_FMA):
       if (validate_arglist (arglist, REAL_TYPE, REAL_TYPE, REAL_TYPE, VOID_TYPE))
 	return do_mpfr_arg3 (TREE_VALUE (arglist),
diff -rup orig/egcc-SVN20070115/gcc/testsuite/gcc.dg/torture/builtin-math-3.c egcc-SVN20070115/gcc/testsuite/gcc.dg/torture/builtin-math-3.c
--- orig/egcc-SVN20070115/gcc/testsuite/gcc.dg/torture/builtin-math-3.c	2006-11-10 09:46:04.000000000 -0500
+++ egcc-SVN20070115/gcc/testsuite/gcc.dg/torture/builtin-math-3.c	2007-01-17 02:27:07.060950957 -0500
@@ -294,6 +294,16 @@ int main (void)
   TESTIT2_R (atan2, -1.0, 0.0, -1.58, -1.57); /* atan2(-1,0) == -pi/2 */
   TESTIT2_R (atan2, 1.0, 0.0, 1.57, 1.58); /* atan2(1,0) == pi/2 */

+  TESTIT2 (fdim, 0.0, 0.0, 0.0); /* fdim(0,0) == 0 */
+  TESTIT2 (fdim, -0.0, 0.0, 0.0); /* fdim(-0,0) == 0 */
+  TESTIT2 (fdim, 0.0, -0.0, 0.0); /* fdim(0,-0) == 0 */
+  TESTIT2 (fdim, -0.0, -0.0, 0.0); /* fdim(-0,-0) == 0 */
+  TESTIT2 (fdim, 5.0, 5.0, 0.0); /* fdim(5,5) == 0 */
+  TESTIT2 (fdim, 5.0, 6.0, 0.0); /* fdim(5,6) == 0 */
+  TESTIT2 (fdim, 6.0, 5.0, 1.0); /* fdim(6,5) == 1 */
+  TESTIT2 (fdim, -5.0, -6.0, 1.0); /* fdim(-5,-6) == 1 */
+  TESTIT2 (fdim, -6.0, -5.0, 0.0); /* fdim(-6,-5) == 0 */
+
   TESTIT2 (fmin, 5.0, 6.0, 5.0); /* fmin(5,6) == 5 */
   TESTIT2 (fmin, 6.0, 5.0, 5.0); /* fmin(6,5) == 5 */
   TESTIT2 (fmin, -5.0, -6.0, -6.0); /* fmin(-5,-6) == -6 */



More information about the Gcc-patches mailing list