Patchwork Fix bitsizetype TYPE_MAX_VALUE

login
register
mail settings
Submitter Richard Guenther
Date Aug. 1, 2011, 11:44 a.m.
Message ID <alpine.LNX.2.00.1108011343540.810@zhemvz.fhfr.qr>
Download mbox | patch
Permalink /patch/107724/
State New
Headers show

Comments

Richard Guenther - Aug. 1, 2011, 11:44 a.m.
This sign-extends it, similar to how we treat TYPE_MAX_VALUE of
sizetype.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.

Richard.

2011-08-01  Richard Guenther  <rguenther@suse.de>

	* stor-layout.c (initialize_sizetypes): Properly sign-extend
	bitsiztype TYPE_MAX_VALUE.

Patch

Index: gcc/stor-layout.c
===================================================================
--- gcc/stor-layout.c	(revision 176998)
+++ gcc/stor-layout.c	(working copy)
@@ -2247,7 +2247,11 @@  initialize_sizetypes (void)
     = size_int (GET_MODE_SIZE (TYPE_MODE (bitsizetype)));
   set_min_and_max_values_for_integral_type (bitsizetype, bprecision,
 					    /*is_unsigned=*/true);
-  /* ???  TYPE_MAX_VALUE is not properly sign-extended.  */
+  /* bitsizetype is unsigned but we need to fix TYPE_MAX_VALUE so that it is
+     sign-extended in a way consistent with force_fit_type.  */
+  TYPE_MAX_VALUE (bitsizetype)
+    = double_int_to_tree (bitsizetype,
+			  tree_to_double_int (TYPE_MAX_VALUE (bitsizetype)));
 
   /* Create the signed variants of *sizetype.  */
   ssizetype = make_signed_type (TYPE_PRECISION (sizetype));