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]: patch to handle builtin rint


This patch addresses item #4 from this posting:
http://gcc.gnu.org/ml/gcc/2004-03/msg00622.html

The patch handles builtin rint like the other integralizing math
functions.  I.e. we return `true' from integer_valued_real_p() and we
allow narrowing the FP type under some circumstances.

Bootstapped on sparc-sun-solaris2.7, no regressions.

Ok for mainline?

		Thanks,
		--Kaveh


2004-03-16  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* builtins.c (integer_valued_real_p): Add builtin rint.
	(fold_builtin): Likewise.
	* convert.c (convert_to_real): Likewise.
	
diff -rup orig/egcc-CVS20040315/gcc/builtins.c egcc-CVS20040315/gcc/builtins.c
--- orig/egcc-CVS20040315/gcc/builtins.c	Sun Mar 14 20:01:12 2004
+++ egcc-CVS20040315/gcc/builtins.c	Tue Mar 16 19:30:54 2004
@@ -5795,6 +5795,9 @@ integer_valued_real_p (tree t)
 	case BUILT_IN_NEARBYINT:
 	case BUILT_IN_NEARBYINTF:
 	case BUILT_IN_NEARBYINTL:
+	case BUILT_IN_RINT:
+	case BUILT_IN_RINTF:
+	case BUILT_IN_RINTL:
 	case BUILT_IN_ROUND:
 	case BUILT_IN_ROUNDF:
 	case BUILT_IN_ROUNDL:
@@ -7044,6 +7047,9 @@ fold_builtin (tree exp)
     case BUILT_IN_NEARBYINT:
     case BUILT_IN_NEARBYINTF:
     case BUILT_IN_NEARBYINTL:
+    case BUILT_IN_RINT:
+    case BUILT_IN_RINTF:
+    case BUILT_IN_RINTL:
       return fold_trunc_transparent_mathfn (exp);
 
     case BUILT_IN_FFS:
diff -rup orig/egcc-CVS20040315/gcc/convert.c egcc-CVS20040315/gcc/convert.c
--- orig/egcc-CVS20040315/gcc/convert.c	Tue Mar 16 19:31:12 2004
+++ egcc-CVS20040315/gcc/convert.c	Tue Mar 16 19:30:54 2004
@@ -175,6 +175,7 @@ convert_to_real (tree type, tree expr)
       && (((fcode == BUILT_IN_FLOORL
 	   || fcode == BUILT_IN_CEILL
 	   || fcode == BUILT_IN_ROUNDL
+	   || fcode == BUILT_IN_RINTL
 	   || fcode == BUILT_IN_TRUNCL
 	   || fcode == BUILT_IN_NEARBYINTL)
 	  && (TYPE_MODE (type) == TYPE_MODE (double_type_node)
@@ -182,6 +183,7 @@ convert_to_real (tree type, tree expr)
 	  || ((fcode == BUILT_IN_FLOOR
 	       || fcode == BUILT_IN_CEIL
 	       || fcode == BUILT_IN_ROUND
+	       || fcode == BUILT_IN_RINT
 	       || fcode == BUILT_IN_TRUNC
 	       || fcode == BUILT_IN_NEARBYINT)
 	      && (TYPE_MODE (type) == TYPE_MODE (float_type_node)))))


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