aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-dfa.c
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@gcc.gnu.org>2012-05-07 18:57:23 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2012-05-07 18:57:23 +0000
commitb48e22b2bd028164829281f676a1e39ede8c3910 (patch)
tree1e60a64abff9d4b063851acc1b758950b2694142 /gcc/tree-dfa.c
parent62beea506bd1a5c688e7b88457408411c8272635 (diff)
downloadgcc-b48e22b2bd028164829281f676a1e39ede8c3910.zip
gcc-b48e22b2bd028164829281f676a1e39ede8c3910.tar.gz
gcc-b48e22b2bd028164829281f676a1e39ede8c3910.tar.bz2
tree-dfa.c (get_ref_base_and_extent): Do the offset computation using the precision of the index type.
* tree-dfa.c (get_ref_base_and_extent) <ARRAY_REF>: Do the offset computation using the precision of the index type. * gimple-fold.c (fold_const_aggregate_ref_1) <ARRAY_REF>: Likewise. (fold_array_ctor_reference): Do index computations in the index type. From-SVN: r187268
Diffstat (limited to 'gcc/tree-dfa.c')
-rw-r--r--gcc/tree-dfa.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/gcc/tree-dfa.c b/gcc/tree-dfa.c
index 0ecec81..3494fc9 100644
--- a/gcc/tree-dfa.c
+++ b/gcc/tree-dfa.c
@@ -814,21 +814,24 @@ get_ref_base_and_extent (tree exp, HOST_WIDE_INT *poffset,
{
tree index = TREE_OPERAND (exp, 1);
tree low_bound, unit_size;
+ double_int doffset;
/* If the resulting bit-offset is constant, track it. */
if (TREE_CODE (index) == INTEGER_CST
- && host_integerp (index, 0)
&& (low_bound = array_ref_low_bound (exp),
- host_integerp (low_bound, 0))
+ TREE_CODE (low_bound) == INTEGER_CST)
&& (unit_size = array_ref_element_size (exp),
- host_integerp (unit_size, 1)))
+ host_integerp (unit_size, 1))
+ && (doffset = double_int_sext
+ (double_int_sub (TREE_INT_CST (index),
+ TREE_INT_CST (low_bound)),
+ TYPE_PRECISION (TREE_TYPE (index))),
+ double_int_fits_in_shwi_p (doffset)))
{
- HOST_WIDE_INT hindex = TREE_INT_CST_LOW (index);
-
- hindex -= TREE_INT_CST_LOW (low_bound);
- hindex *= TREE_INT_CST_LOW (unit_size);
- hindex *= BITS_PER_UNIT;
- bit_offset += hindex;
+ HOST_WIDE_INT hoffset = double_int_to_shwi (doffset);
+ hoffset *= TREE_INT_CST_LOW (unit_size);
+ hoffset *= BITS_PER_UNIT;
+ bit_offset += hoffset;
/* An array ref with a constant index up in the structure
hierarchy will constrain the size of any variable array ref