This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Get rid of awkward precision for bitsize types
- From: Eric Botcazou <ebotcazou at adacore dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 6 Apr 2009 12:24:16 +0200
- Subject: [PATCH] Get rid of awkward precision for bitsize types
Hi,
the base formula to compute it is (oprecision + BITS_PER_UNIT_LOG + 1) where
oprecision is the precision of sizetype; this yields 36 for typical 32-bit
targets so bitsize types are DImode integer types with 36-bit precision.
This means that the RTL expander will generate mask and shift instructions to
maintain the precision, for example 1.2 MB out of 85 MB at -O0 for a big Ada
application.
An approach to eliminating this unwanted effect would be to exclude sizetypes
from the RTL expander treatment; another is to make it so that bitsize types
use the full precision of their machine mode.
Tested on i586-suse-linux, OK for mainline?
2009-04-06 Eric Botcazou <ebotcazou@adacore.com>
* stor-layout.c (set_sizetype): Use the full precision of their
machine mode for bitsize types.
--
Eric Botcazou
Index: stor-layout.c
===================================================================
--- stor-layout.c (revision 145500)
+++ stor-layout.c (working copy)
@@ -2046,15 +2046,18 @@ initialize_sizetypes (bool signed_p)
void
set_sizetype (tree type)
{
+ tree t;
int oprecision = TYPE_PRECISION (type);
/* The *bitsizetype types use a precision that avoids overflows when
calculating signed sizes / offsets in bits. However, when
cross-compiling from a 32 bit to a 64 bit host, we are limited to 64 bit
precision. */
- int precision = MIN (MIN (oprecision + BITS_PER_UNIT_LOG + 1,
- MAX_FIXED_MODE_SIZE),
- 2 * HOST_BITS_PER_WIDE_INT);
- tree t;
+ int precision
+ = MIN (oprecision + BITS_PER_UNIT_LOG + 1, MAX_FIXED_MODE_SIZE);
+ precision
+ = GET_MODE_PRECISION (smallest_mode_for_size (precision, MODE_INT));
+ if (precision > HOST_BITS_PER_WIDE_INT * 2)
+ precision = HOST_BITS_PER_WIDE_INT * 2;
gcc_assert (TYPE_UNSIGNED (type) == TYPE_UNSIGNED (sizetype));