summaryrefslogtreecommitdiff
path: root/gcc/tree-dfa.c
diff options
context:
space:
mode:
authorebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>2012-05-07 18:57:23 +0000
committerebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>2012-05-07 18:57:23 +0000
commit96c3acd0bb2761fd13b49de3469db1fc5d354991 (patch)
tree1e60a64abff9d4b063851acc1b758950b2694142 /gcc/tree-dfa.c
parent254aacff3837b5c4817b1aef03dfa0b4d53ae5eb (diff)
downloadgcc-96c3acd0bb2761fd13b49de3469db1fc5d354991.tar.gz
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@187268 138bc75d-0d04-0410-961f-82ee72b054a4
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 0ecec816b6a..3494fc9e962 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