* [PATCH] Fix uncanonical integer csts
@ 2011-04-18 14:18 Richard Guenther
0 siblings, 0 replies; only message in thread
From: Richard Guenther @ 2011-04-18 14:18 UTC (permalink / raw)
To: gcc-patches
This fixes up upper_bound_in_type and lower_bound_in_type which
build non-canonical integer csts for sizetype.
Bootstrapped and tested on x86_64-unknown-linux-gnu, installed.
Richard.
2011-04-18 Richard Guenther <rguenther@suse.de>
* tree.c (upper_bound_in_type): Build properly canonicalized
INTEGER_CSTs.
(lower_bound_in_type): Likewise.
Index: gcc/tree.c
===================================================================
--- gcc/tree.c (revision 172644)
+++ gcc/tree.c (working copy)
@@ -9964,7 +9964,7 @@ signed_type_for (tree type)
tree
upper_bound_in_type (tree outer, tree inner)
{
- unsigned HOST_WIDE_INT lo, hi;
+ double_int high;
unsigned int det = 0;
unsigned oprec = TYPE_PRECISION (outer);
unsigned iprec = TYPE_PRECISION (inner);
@@ -10011,18 +10011,18 @@ upper_bound_in_type (tree outer, tree in
/* Compute 2^^prec - 1. */
if (prec <= HOST_BITS_PER_WIDE_INT)
{
- hi = 0;
- lo = ((~(unsigned HOST_WIDE_INT) 0)
+ high.high = 0;
+ high.low = ((~(unsigned HOST_WIDE_INT) 0)
>> (HOST_BITS_PER_WIDE_INT - prec));
}
else
{
- hi = ((~(unsigned HOST_WIDE_INT) 0)
+ high.high = ((~(unsigned HOST_WIDE_INT) 0)
>> (2 * HOST_BITS_PER_WIDE_INT - prec));
- lo = ~(unsigned HOST_WIDE_INT) 0;
+ high.low = ~(unsigned HOST_WIDE_INT) 0;
}
- return build_int_cst_wide (outer, lo, hi);
+ return double_int_to_tree (outer, high);
}
/* Returns the smallest value obtainable by casting something in INNER type to
@@ -10031,7 +10031,7 @@ upper_bound_in_type (tree outer, tree in
tree
lower_bound_in_type (tree outer, tree inner)
{
- unsigned HOST_WIDE_INT lo, hi;
+ double_int low;
unsigned oprec = TYPE_PRECISION (outer);
unsigned iprec = TYPE_PRECISION (inner);
@@ -10042,7 +10042,7 @@ lower_bound_in_type (tree outer, tree in
contains all values of INNER type. In particular, both INNER
and OUTER types have zero in common. */
|| (oprec > iprec && TYPE_UNSIGNED (inner)))
- lo = hi = 0;
+ low.low = low.high = 0;
else
{
/* If we are widening a signed type to another signed type, we
@@ -10053,18 +10053,18 @@ lower_bound_in_type (tree outer, tree in
if (prec <= HOST_BITS_PER_WIDE_INT)
{
- hi = ~(unsigned HOST_WIDE_INT) 0;
- lo = (~(unsigned HOST_WIDE_INT) 0) << (prec - 1);
+ low.high = ~(unsigned HOST_WIDE_INT) 0;
+ low.low = (~(unsigned HOST_WIDE_INT) 0) << (prec - 1);
}
else
{
- hi = ((~(unsigned HOST_WIDE_INT) 0)
+ low.high = ((~(unsigned HOST_WIDE_INT) 0)
<< (prec - HOST_BITS_PER_WIDE_INT - 1));
- lo = 0;
+ low.low = 0;
}
}
- return build_int_cst_wide (outer, lo, hi);
+ return double_int_to_tree (outer, low);
}
/* Return nonzero if two operands that are suitable for PHI nodes are
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2011-04-18 13:57 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-18 14:18 [PATCH] Fix uncanonical integer csts Richard Guenther
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).