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] Fix int_fits_type_p (PR tree-optimization/37525)


Hi!

The recent int_fits_type_p fix for sizetype constants degrades generated
Fortran code, because size_type_node is a signed type in Fortran.  So
after force_fit_type_double original say (sizetype) -25 (i.e. weirdly
encoded -25UL) will become -25L, so it won't even fit into its own type,
which has type_lower_bound 0 and -25 is smaller than that.
With this patch we use an unsigned type always, for C/C++ unsigned_type_for
will just return the passed type immediately, as it has TYPE_UNSIGNED set.

Ok for trunk?

2008-09-17  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/37525
	* tree.c (int_fits_type_p): Fix last change if size_type_node is
	signed.

--- gcc/tree.c.jj	2008-09-17 17:58:44.000000000 +0200
+++ gcc/tree.c	2008-09-17 19:07:33.000000000 +0200
@@ -6425,7 +6425,7 @@ int_fits_type_p (const_tree c, const_tre
 	 means the higher end bits are set to 1 only for sign extension.
 	 So let's convert c into an equivalent zero extended unsigned
 	 integer.  */
-      c = force_fit_type_double (size_type_node,
+      c = force_fit_type_double (unsigned_type_for (size_type_node),
 				 TREE_INT_CST_LOW (c),
 				 TREE_INT_CST_HIGH (c),
 				 false, false);

	Jakub


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