Commit 75e802cc by Richard Guenther Committed by Richard Biener

tree.c (upper_bound_in_type): Build properly canonicalized INTEGER_CSTs.

2011-04-18  Richard Guenther  <rguenther@suse.de>

	* tree.c (upper_bound_in_type): Build properly canonicalized
	INTEGER_CSTs.
	(lower_bound_in_type): Likewise.

From-SVN: r172645
parent 3b45a007
2011-04-18 Richard Guenther <rguenther@suse.de> 2011-04-18 Richard Guenther <rguenther@suse.de>
* tree.c (upper_bound_in_type): Build properly canonicalized
INTEGER_CSTs.
(lower_bound_in_type): Likewise.
2011-04-18 Richard Guenther <rguenther@suse.de>
* gimple.h (gimple_call_addr_fndecl): New function. * gimple.h (gimple_call_addr_fndecl): New function.
(gimple_call_fndecl): Use it. (gimple_call_fndecl): Use it.
* gimple-fold.c (gimple_fold_call): Fold away OBJ_TYPE_REFs * gimple-fold.c (gimple_fold_call): Fold away OBJ_TYPE_REFs
......
...@@ -9964,7 +9964,7 @@ signed_type_for (tree type) ...@@ -9964,7 +9964,7 @@ signed_type_for (tree type)
tree tree
upper_bound_in_type (tree outer, tree inner) upper_bound_in_type (tree outer, tree inner)
{ {
unsigned HOST_WIDE_INT lo, hi; double_int high;
unsigned int det = 0; unsigned int det = 0;
unsigned oprec = TYPE_PRECISION (outer); unsigned oprec = TYPE_PRECISION (outer);
unsigned iprec = TYPE_PRECISION (inner); unsigned iprec = TYPE_PRECISION (inner);
...@@ -10011,18 +10011,18 @@ upper_bound_in_type (tree outer, tree inner) ...@@ -10011,18 +10011,18 @@ upper_bound_in_type (tree outer, tree inner)
/* Compute 2^^prec - 1. */ /* Compute 2^^prec - 1. */
if (prec <= HOST_BITS_PER_WIDE_INT) if (prec <= HOST_BITS_PER_WIDE_INT)
{ {
hi = 0; high.high = 0;
lo = ((~(unsigned HOST_WIDE_INT) 0) high.low = ((~(unsigned HOST_WIDE_INT) 0)
>> (HOST_BITS_PER_WIDE_INT - prec)); >> (HOST_BITS_PER_WIDE_INT - prec));
} }
else else
{ {
hi = ((~(unsigned HOST_WIDE_INT) 0) high.high = ((~(unsigned HOST_WIDE_INT) 0)
>> (2 * HOST_BITS_PER_WIDE_INT - prec)); >> (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 /* Returns the smallest value obtainable by casting something in INNER type to
...@@ -10031,7 +10031,7 @@ upper_bound_in_type (tree outer, tree inner) ...@@ -10031,7 +10031,7 @@ upper_bound_in_type (tree outer, tree inner)
tree tree
lower_bound_in_type (tree outer, tree inner) lower_bound_in_type (tree outer, tree inner)
{ {
unsigned HOST_WIDE_INT lo, hi; double_int low;
unsigned oprec = TYPE_PRECISION (outer); unsigned oprec = TYPE_PRECISION (outer);
unsigned iprec = TYPE_PRECISION (inner); unsigned iprec = TYPE_PRECISION (inner);
...@@ -10042,7 +10042,7 @@ lower_bound_in_type (tree outer, tree inner) ...@@ -10042,7 +10042,7 @@ lower_bound_in_type (tree outer, tree inner)
contains all values of INNER type. In particular, both INNER contains all values of INNER type. In particular, both INNER
and OUTER types have zero in common. */ and OUTER types have zero in common. */
|| (oprec > iprec && TYPE_UNSIGNED (inner))) || (oprec > iprec && TYPE_UNSIGNED (inner)))
lo = hi = 0; low.low = low.high = 0;
else else
{ {
/* If we are widening a signed type to another signed type, we /* If we are widening a signed type to another signed type, we
...@@ -10053,18 +10053,18 @@ lower_bound_in_type (tree outer, tree inner) ...@@ -10053,18 +10053,18 @@ lower_bound_in_type (tree outer, tree inner)
if (prec <= HOST_BITS_PER_WIDE_INT) if (prec <= HOST_BITS_PER_WIDE_INT)
{ {
hi = ~(unsigned HOST_WIDE_INT) 0; low.high = ~(unsigned HOST_WIDE_INT) 0;
lo = (~(unsigned HOST_WIDE_INT) 0) << (prec - 1); low.low = (~(unsigned HOST_WIDE_INT) 0) << (prec - 1);
} }
else else
{ {
hi = ((~(unsigned HOST_WIDE_INT) 0) low.high = ((~(unsigned HOST_WIDE_INT) 0)
<< (prec - HOST_BITS_PER_WIDE_INT - 1)); << (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 /* Return nonzero if two operands that are suitable for PHI nodes are
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment