diff options
author | Richard Guenther <rguenther@suse.de> | 2007-01-08 22:17:43 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2007-01-08 22:17:43 +0000 |
commit | 2b60792f2b31e4b305033502a6717a76308dff50 (patch) | |
tree | 97a13c6eafb874c8f14484040aaf7da2c160f41f /gcc/tree.c | |
parent | 61fcaeefb219b791d9161525fb2fd83066693898 (diff) | |
download | gcc-2b60792f2b31e4b305033502a6717a76308dff50.zip gcc-2b60792f2b31e4b305033502a6717a76308dff50.tar.gz gcc-2b60792f2b31e4b305033502a6717a76308dff50.tar.bz2 |
builtins.c (fold_builtin_int_roundingfn): Use fit_double_type.
2007-01-08 Richard Guenther <rguenther@suse.de>
* builtins.c (fold_builtin_int_roundingfn): Use fit_double_type.
* tree.c (build_int_cst_type): Likewise.
(size_in_bytes): Don't call force_fit_type on the result.
(int_fits_type_p): Use fit_double_type.
* fold-const.c (fit_double_type): New function.
(force_fit_type): Use it.
* tree.h (fit_double_type): Export.
From-SVN: r120593
Diffstat (limited to 'gcc/tree.c')
-rw-r--r-- | gcc/tree.c | 67 |
1 files changed, 12 insertions, 55 deletions
@@ -779,53 +779,14 @@ build_int_cstu (tree type, unsigned HOST_WIDE_INT low) tree build_int_cst_type (tree type, HOST_WIDE_INT low) { - unsigned HOST_WIDE_INT val = (unsigned HOST_WIDE_INT) low; - unsigned HOST_WIDE_INT hi, mask; - unsigned bits; - bool signed_p; - bool negative; + unsigned HOST_WIDE_INT low1; + HOST_WIDE_INT hi; - if (!type) - type = integer_type_node; - - bits = TYPE_PRECISION (type); - signed_p = !TYPE_UNSIGNED (type); - - if (bits >= HOST_BITS_PER_WIDE_INT) - negative = (low < 0); - else - { - /* If the sign bit is inside precision of LOW, use it to determine - the sign of the constant. */ - negative = ((val >> (bits - 1)) & 1) != 0; - - /* Mask out the bits outside of the precision of the constant. */ - mask = (((unsigned HOST_WIDE_INT) 2) << (bits - 1)) - 1; - - if (signed_p && negative) - val |= ~mask; - else - val &= mask; - } - - /* Determine the high bits. */ - hi = (negative ? ~(unsigned HOST_WIDE_INT) 0 : 0); + gcc_assert (type); - /* For unsigned type we need to mask out the bits outside of the type - precision. */ - if (!signed_p) - { - if (bits <= HOST_BITS_PER_WIDE_INT) - hi = 0; - else - { - bits -= HOST_BITS_PER_WIDE_INT; - mask = (((unsigned HOST_WIDE_INT) 2) << (bits - 1)) - 1; - hi &= mask; - } - } + fit_double_type (low, low < 0 ? -1 : 0, &low1, &hi, type); - return build_int_cst_wide (type, val, hi); + return build_int_cst_wide (type, low1, hi); } /* These are the hash table functions for the hash table of INTEGER_CST @@ -1818,9 +1779,6 @@ size_in_bytes (tree type) return size_zero_node; } - if (TREE_CODE (t) == INTEGER_CST) - t = force_fit_type (t, 0, false, false); - return t; } @@ -6009,12 +5967,13 @@ int_fits_type_p (tree c, tree type) tree type_low_bound = TYPE_MIN_VALUE (type); tree type_high_bound = TYPE_MAX_VALUE (type); bool ok_for_low_bound, ok_for_high_bound; - tree tmp; + unsigned HOST_WIDE_INT low; + HOST_WIDE_INT high; /* 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 this type is a subtype, try checking against that. Otherwise, use - force_fit_type, which checks against the precision. + fit_double_type, which checks against the precision. 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 @@ -6069,12 +6028,10 @@ int_fits_type_p (tree c, tree type) && TYPE_PRECISION (type) == TYPE_PRECISION (TREE_TYPE (type))) return int_fits_type_p (c, TREE_TYPE (type)); - /* Or to force_fit_type, if nothing else. */ - tmp = copy_node (c); - TREE_TYPE (tmp) = type; - tmp = force_fit_type (tmp, -1, false, false); - return TREE_INT_CST_HIGH (tmp) == TREE_INT_CST_HIGH (c) - && TREE_INT_CST_LOW (tmp) == TREE_INT_CST_LOW (c); + /* Or to fit_double_type, if nothing else. */ + low = TREE_INT_CST_LOW (c); + high = TREE_INT_CST_HIGH (c); + return !fit_double_type (low, high, &low, &high, type); } /* Subprogram of following function. Called by walk_tree. |