Commit 88e06841 by Anatoly Sokolov Committed by Anatoly Sokolov

double-int.h (fit_double_type): Remove declaration.

	* double-int.h (fit_double_type): Remove declaration.
	* double-int.c (fit_double_type): Remove function.
	* tree.h (int_fits_type_p): Adjust prototype.
	* tree.c (int_fits_type_p): Return bool. Use double_int_fits_to_tree_p
	instead of fit_double_type.
	(build_int_cst_type): Use double_int_to_tree and shwi_to_double_int
	instead of fit_double_type and build_int_cst_wide.
	* builtins.c (): Use double_int_fits_to_tree_p and double_int_to_tree
	instead of fit_double_type and build_int_cst_wide.
	(fold_builtin_object_size): Use double_int_fits_to_tree_p instead
	of fit_double_type.

From-SVN: r161847
parent 92eb4438
2010-07-05 Anatoly Sokolov <aesok@post.ru>
* double-int.h (fit_double_type): Remove declaration.
* double-int.c (fit_double_type): Remove function.
* tree.h (int_fits_type_p): Adjust prototype.
* tree.c (int_fits_type_p): Return bool. Use double_int_fits_to_tree_p
instead of fit_double_type.
(build_int_cst_type): Use double_int_to_tree and shwi_to_double_int
instead of fit_double_type and build_int_cst_wide.
* builtins.c (): Use double_int_fits_to_tree_p and double_int_to_tree
instead of fit_double_type and build_int_cst_wide.
(fold_builtin_object_size): Use double_int_fits_to_tree_p instead
of fit_double_type.
2010-07-05 Jan Hubicka <jh@suse.cz> 2010-07-05 Jan Hubicka <jh@suse.cz>
* cgraph.h (cgraph_node, cgraph_varpool_node): Update docmentation of * cgraph.h (cgraph_node, cgraph_varpool_node): Update docmentation of
......
...@@ -7626,8 +7626,7 @@ fold_builtin_int_roundingfn (location_t loc, tree fndecl, tree arg) ...@@ -7626,8 +7626,7 @@ fold_builtin_int_roundingfn (location_t loc, tree fndecl, tree arg)
{ {
tree itype = TREE_TYPE (TREE_TYPE (fndecl)); tree itype = TREE_TYPE (TREE_TYPE (fndecl));
tree ftype = TREE_TYPE (arg); tree ftype = TREE_TYPE (arg);
unsigned HOST_WIDE_INT lo2; double_int val;
HOST_WIDE_INT hi, lo;
REAL_VALUE_TYPE r; REAL_VALUE_TYPE r;
switch (DECL_FUNCTION_CODE (fndecl)) switch (DECL_FUNCTION_CODE (fndecl))
...@@ -7651,9 +7650,9 @@ fold_builtin_int_roundingfn (location_t loc, tree fndecl, tree arg) ...@@ -7651,9 +7650,9 @@ fold_builtin_int_roundingfn (location_t loc, tree fndecl, tree arg)
gcc_unreachable (); gcc_unreachable ();
} }
REAL_VALUE_TO_INT (&lo, &hi, r); real_to_integer2 ((HOST_WIDE_INT *)&val.low, &val.high, &r);
if (!fit_double_type (lo, hi, &lo2, &hi, itype)) if (double_int_fits_to_tree_p (itype, val))
return build_int_cst_wide (itype, lo2, hi); return double_int_to_tree (itype, val);
} }
} }
...@@ -12036,7 +12035,7 @@ maybe_emit_free_warning (tree exp) ...@@ -12036,7 +12035,7 @@ maybe_emit_free_warning (tree exp)
tree tree
fold_builtin_object_size (tree ptr, tree ost) fold_builtin_object_size (tree ptr, tree ost)
{ {
tree ret = NULL_TREE; unsigned HOST_WIDE_INT bytes;
int object_size_type; int object_size_type;
if (!validate_arg (ptr, POINTER_TYPE) if (!validate_arg (ptr, POINTER_TYPE)
...@@ -12059,31 +12058,25 @@ fold_builtin_object_size (tree ptr, tree ost) ...@@ -12059,31 +12058,25 @@ fold_builtin_object_size (tree ptr, tree ost)
return build_int_cst_type (size_type_node, object_size_type < 2 ? -1 : 0); return build_int_cst_type (size_type_node, object_size_type < 2 ? -1 : 0);
if (TREE_CODE (ptr) == ADDR_EXPR) if (TREE_CODE (ptr) == ADDR_EXPR)
ret = build_int_cstu (size_type_node, {
compute_builtin_object_size (ptr, object_size_type)); bytes = compute_builtin_object_size (ptr, object_size_type);
if (double_int_fits_to_tree_p (size_type_node,
uhwi_to_double_int (bytes)))
return build_int_cstu (size_type_node, bytes);
}
else if (TREE_CODE (ptr) == SSA_NAME) else if (TREE_CODE (ptr) == SSA_NAME)
{ {
unsigned HOST_WIDE_INT bytes;
/* If object size is not known yet, delay folding until /* If object size is not known yet, delay folding until
later. Maybe subsequent passes will help determining later. Maybe subsequent passes will help determining
it. */ it. */
bytes = compute_builtin_object_size (ptr, object_size_type); bytes = compute_builtin_object_size (ptr, object_size_type);
if (bytes != (unsigned HOST_WIDE_INT) (object_size_type < 2 if (bytes != (unsigned HOST_WIDE_INT) (object_size_type < 2 ? -1 : 0)
? -1 : 0)) && double_int_fits_to_tree_p (size_type_node,
ret = build_int_cstu (size_type_node, bytes); uhwi_to_double_int (bytes)))
return build_int_cstu (size_type_node, bytes);
} }
if (ret) return NULL_TREE;
{
unsigned HOST_WIDE_INT low = TREE_INT_CST_LOW (ret);
HOST_WIDE_INT high = TREE_INT_CST_HIGH (ret);
if (fit_double_type (low, high, &low, &high, TREE_TYPE (ret)))
ret = NULL_TREE;
}
return ret;
} }
/* Fold a call to the __mem{cpy,pcpy,move,set}_chk builtin. /* Fold a call to the __mem{cpy,pcpy,move,set}_chk builtin.
......
...@@ -69,71 +69,6 @@ decode (HOST_WIDE_INT *words, unsigned HOST_WIDE_INT *low, ...@@ -69,71 +69,6 @@ decode (HOST_WIDE_INT *words, unsigned HOST_WIDE_INT *low,
*hi = words[2] + words[3] * BASE; *hi = words[2] + words[3] * BASE;
} }
/* Force the double-word integer L1, H1 to be within the range of the
integer type TYPE. Stores the properly truncated and sign-extended
double-word integer in *LV, *HV. Returns true if the operation
overflows, that is, argument and result are different. */
int
fit_double_type (unsigned HOST_WIDE_INT l1, HOST_WIDE_INT h1,
unsigned HOST_WIDE_INT *lv, HOST_WIDE_INT *hv, const_tree type)
{
unsigned HOST_WIDE_INT low0 = l1;
HOST_WIDE_INT high0 = h1;
unsigned int prec = TYPE_PRECISION (type);
int sign_extended_type;
/* Size types *are* sign extended. */
sign_extended_type = (!TYPE_UNSIGNED (type)
|| (TREE_CODE (type) == INTEGER_TYPE
&& TYPE_IS_SIZETYPE (type)));
/* First clear all bits that are beyond the type's precision. */
if (prec >= 2 * HOST_BITS_PER_WIDE_INT)
;
else if (prec > HOST_BITS_PER_WIDE_INT)
h1 &= ~((HOST_WIDE_INT) (-1) << (prec - HOST_BITS_PER_WIDE_INT));
else
{
h1 = 0;
if (prec < HOST_BITS_PER_WIDE_INT)
l1 &= ~((HOST_WIDE_INT) (-1) << prec);
}
/* Then do sign extension if necessary. */
if (!sign_extended_type)
/* No sign extension */;
else if (prec >= 2 * HOST_BITS_PER_WIDE_INT)
/* Correct width already. */;
else if (prec > HOST_BITS_PER_WIDE_INT)
{
/* Sign extend top half? */
if (h1 & ((unsigned HOST_WIDE_INT)1
<< (prec - HOST_BITS_PER_WIDE_INT - 1)))
h1 |= (HOST_WIDE_INT) (-1) << (prec - HOST_BITS_PER_WIDE_INT);
}
else if (prec == HOST_BITS_PER_WIDE_INT)
{
if ((HOST_WIDE_INT)l1 < 0)
h1 = -1;
}
else
{
/* Sign extend bottom half? */
if (l1 & ((unsigned HOST_WIDE_INT)1 << (prec - 1)))
{
h1 = -1;
l1 |= (HOST_WIDE_INT)(-1) << prec;
}
}
*lv = l1;
*hv = h1;
/* If the value didn't fit, signal overflow. */
return l1 != low0 || h1 != high0;
}
/* Add two doubleword integers with doubleword result. /* Add two doubleword integers with doubleword result.
Return nonzero if the operation overflows according to UNSIGNED_P. Return nonzero if the operation overflows according to UNSIGNED_P.
Each argument is given as two `HOST_WIDE_INT' pieces. Each argument is given as two `HOST_WIDE_INT' pieces.
......
...@@ -270,9 +270,6 @@ double_int_equal_p (double_int cst1, double_int cst2) ...@@ -270,9 +270,6 @@ double_int_equal_p (double_int cst1, double_int cst2)
/* Legacy interface with decomposed high/low parts. */ /* Legacy interface with decomposed high/low parts. */
extern int fit_double_type (unsigned HOST_WIDE_INT, HOST_WIDE_INT,
unsigned HOST_WIDE_INT *, HOST_WIDE_INT *,
const_tree);
extern int add_double_with_sign (unsigned HOST_WIDE_INT, HOST_WIDE_INT, extern int add_double_with_sign (unsigned HOST_WIDE_INT, HOST_WIDE_INT,
unsigned HOST_WIDE_INT, HOST_WIDE_INT, unsigned HOST_WIDE_INT, HOST_WIDE_INT,
unsigned HOST_WIDE_INT *, HOST_WIDE_INT *, unsigned HOST_WIDE_INT *, HOST_WIDE_INT *,
......
...@@ -1049,14 +1049,9 @@ build_int_cst (tree type, HOST_WIDE_INT low) ...@@ -1049,14 +1049,9 @@ build_int_cst (tree type, HOST_WIDE_INT low)
tree tree
build_int_cst_type (tree type, HOST_WIDE_INT low) build_int_cst_type (tree type, HOST_WIDE_INT low)
{ {
unsigned HOST_WIDE_INT low1;
HOST_WIDE_INT hi;
gcc_assert (type); gcc_assert (type);
fit_double_type (low, low < 0 ? -1 : 0, &low1, &hi, type); return double_int_to_tree (type, shwi_to_double_int (low));
return build_int_cst_wide (type, low1, hi);
} }
/* Constructs tree in type TYPE from with value given by CST. Signedness /* Constructs tree in type TYPE from with value given by CST. Signedness
...@@ -7900,10 +7895,10 @@ get_narrower (tree op, int *unsignedp_ptr) ...@@ -7900,10 +7895,10 @@ get_narrower (tree op, int *unsignedp_ptr)
return win; return win;
} }
/* Nonzero if integer constant C has a value that is permissible /* Returns true if integer constant C has a value that is permissible
for type TYPE (an INTEGER_TYPE). */ for type TYPE (an INTEGER_TYPE). */
int bool
int_fits_type_p (const_tree c, const_tree type) int_fits_type_p (const_tree c, const_tree type)
{ {
tree type_low_bound, type_high_bound; tree type_low_bound, type_high_bound;
...@@ -7932,7 +7927,7 @@ retry: ...@@ -7932,7 +7927,7 @@ retry:
/* If at least one bound of the type is a constant integer, we can check /* If at least one bound of the type is a constant integer, we can check
ourselves and maybe make a decision. If no such decision is possible, but ourselves and maybe make a decision. If no such decision is possible, but
this type is a subtype, try checking against that. Otherwise, use this type is a subtype, try checking against that. Otherwise, use
fit_double_type, which checks against the precision. double_int_fits_to_tree_p, which checks against the precision.
Compute the status for each possibly constant bound, and return if we see Compute the status for each possibly constant bound, and return if we see
one does not match. Use ok_for_xxx_bound for this purpose, assigning -1 one does not match. Use ok_for_xxx_bound for this purpose, assigning -1
...@@ -7953,12 +7948,12 @@ retry: ...@@ -7953,12 +7948,12 @@ retry:
int t_neg = (unsc && double_int_negative_p (dd)); int t_neg = (unsc && double_int_negative_p (dd));
if (c_neg && !t_neg) if (c_neg && !t_neg)
return 0; return false;
if ((c_neg || !t_neg) && double_int_ucmp (dc, dd) < 0) if ((c_neg || !t_neg) && double_int_ucmp (dc, dd) < 0)
return 0; return false;
} }
else if (double_int_cmp (dc, dd, unsc) < 0) else if (double_int_cmp (dc, dd, unsc) < 0)
return 0; return false;
ok_for_low_bound = true; ok_for_low_bound = true;
} }
else else
...@@ -7978,12 +7973,12 @@ retry: ...@@ -7978,12 +7973,12 @@ retry:
int t_neg = (unsc && double_int_negative_p (dd)); int t_neg = (unsc && double_int_negative_p (dd));
if (t_neg && !c_neg) if (t_neg && !c_neg)
return 0; return false;
if ((t_neg || !c_neg) && double_int_ucmp (dc, dd) > 0) if ((t_neg || !c_neg) && double_int_ucmp (dc, dd) > 0)
return 0; return false;
} }
else if (double_int_cmp (dc, dd, unsc) > 0) else if (double_int_cmp (dc, dd, unsc) > 0)
return 0; return false;
ok_for_high_bound = true; ok_for_high_bound = true;
} }
else else
...@@ -7991,17 +7986,17 @@ retry: ...@@ -7991,17 +7986,17 @@ retry:
/* If the constant fits both bounds, the result is known. */ /* If the constant fits both bounds, the result is known. */
if (ok_for_low_bound && ok_for_high_bound) if (ok_for_low_bound && ok_for_high_bound)
return 1; return true;
/* Perform some generic filtering which may allow making a decision /* Perform some generic filtering which may allow making a decision
even if the bounds are not constant. First, negative integers even if the bounds are not constant. First, negative integers
never fit in unsigned types, */ never fit in unsigned types, */
if (TYPE_UNSIGNED (type) && !unsc && double_int_negative_p (dc)) if (TYPE_UNSIGNED (type) && !unsc && double_int_negative_p (dc))
return 0; return false;
/* Second, narrower types always fit in wider ones. */ /* Second, narrower types always fit in wider ones. */
if (TYPE_PRECISION (type) > TYPE_PRECISION (TREE_TYPE (c))) if (TYPE_PRECISION (type) > TYPE_PRECISION (TREE_TYPE (c)))
return 1; return true;
/* Third, unsigned integers with top bit set never fit signed types. */ /* Third, unsigned integers with top bit set never fit signed types. */
if (! TYPE_UNSIGNED (type) && unsc) if (! TYPE_UNSIGNED (type) && unsc)
...@@ -8010,11 +8005,11 @@ retry: ...@@ -8010,11 +8005,11 @@ retry:
if (prec < HOST_BITS_PER_WIDE_INT) if (prec < HOST_BITS_PER_WIDE_INT)
{ {
if (((((unsigned HOST_WIDE_INT) 1) << prec) & dc.low) != 0) if (((((unsigned HOST_WIDE_INT) 1) << prec) & dc.low) != 0)
return 0; return false;
} }
else if (((((unsigned HOST_WIDE_INT) 1) else if (((((unsigned HOST_WIDE_INT) 1)
<< (prec - HOST_BITS_PER_WIDE_INT)) & dc.high) != 0) << (prec - HOST_BITS_PER_WIDE_INT)) & dc.high) != 0)
return 0; return false;
} }
/* If we haven't been able to decide at this point, there nothing more we /* If we haven't been able to decide at this point, there nothing more we
...@@ -8028,8 +8023,8 @@ retry: ...@@ -8028,8 +8023,8 @@ retry:
goto retry; goto retry;
} }
/* Or to fit_double_type, if nothing else. */ /* Or to double_int_fits_to_tree_p, if nothing else. */
return !fit_double_type (dc.low, dc.high, &dc.low, &dc.high, type); return double_int_fits_to_tree_p (type, dc);
} }
/* Stores bounds of an integer TYPE in MIN and MAX. If TYPE has non-constant /* Stores bounds of an integer TYPE in MIN and MAX. If TYPE has non-constant
......
...@@ -5049,7 +5049,7 @@ extern tree strip_float_extensions (tree); ...@@ -5049,7 +5049,7 @@ extern tree strip_float_extensions (tree);
extern int really_constant_p (const_tree); extern int really_constant_p (const_tree);
extern bool decl_address_invariant_p (const_tree); extern bool decl_address_invariant_p (const_tree);
extern bool decl_address_ip_invariant_p (const_tree); extern bool decl_address_ip_invariant_p (const_tree);
extern int int_fits_type_p (const_tree, const_tree); extern bool int_fits_type_p (const_tree, const_tree);
#ifndef GENERATOR_FILE #ifndef GENERATOR_FILE
extern void get_type_static_bounds (const_tree, mpz_t, mpz_t); extern void get_type_static_bounds (const_tree, mpz_t, mpz_t);
#endif #endif
......
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