From c21c775aebda19b465d7fef576fb078cabac4a71 Mon Sep 17 00:00:00 2001 From: Richard Guenther Date: Tue, 27 Mar 2007 15:40:09 +0000 Subject: [PATCH] tree-dfa.c (get_ref_base_and_extent): Replace bit_offset and computations with it with a HOST_WIDE_INT variable. 2007-03-27 Richard Guenther * tree-dfa.c (get_ref_base_and_extent): Replace bit_offset and computations with it with a HOST_WIDE_INT variable. From-SVN: r123259 --- gcc/ChangeLog | 5 +++++ gcc/tree-dfa.c | 53 ++++++++++++++++++++++---------------------------- 2 files changed, 28 insertions(+), 30 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1f5a44c8f47..7600b6e05f1 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2007-03-27 Richard Guenther + + * tree-dfa.c (get_ref_base_and_extent): Replace bit_offset and + computations with it with a HOST_WIDE_INT variable. + 2007-03-26 Mike Stump * config/rs6000/darwin.h (DARWIN_MINVERSION_SPEC): Add diff --git a/gcc/tree-dfa.c b/gcc/tree-dfa.c index a1200eb4ebd..b23c531cadc 100644 --- a/gcc/tree-dfa.c +++ b/gcc/tree-dfa.c @@ -859,7 +859,7 @@ get_ref_base_and_extent (tree exp, HOST_WIDE_INT *poffset, HOST_WIDE_INT bitsize = -1; HOST_WIDE_INT maxsize = -1; tree size_tree = NULL_TREE; - tree bit_offset = bitsize_zero_node; + HOST_WIDE_INT bit_offset = 0; bool seen_variable_array_ref = false; gcc_assert (!SSA_VAR_P (exp)); @@ -896,8 +896,7 @@ get_ref_base_and_extent (tree exp, HOST_WIDE_INT *poffset, switch (TREE_CODE (exp)) { case BIT_FIELD_REF: - bit_offset = size_binop (PLUS_EXPR, bit_offset, - TREE_OPERAND (exp, 2)); + bit_offset += tree_low_cst (TREE_OPERAND (exp, 2), 1); break; case COMPONENT_REF: @@ -907,14 +906,11 @@ get_ref_base_and_extent (tree exp, HOST_WIDE_INT *poffset, if (this_offset && TREE_CODE (this_offset) == INTEGER_CST) { - this_offset = size_binop (MULT_EXPR, - fold_convert (bitsizetype, - this_offset), - bitsize_unit_node); - bit_offset = size_binop (PLUS_EXPR, - bit_offset, this_offset); - bit_offset = size_binop (PLUS_EXPR, bit_offset, - DECL_FIELD_BIT_OFFSET (field)); + HOST_WIDE_INT hthis_offset = tree_low_cst (this_offset, 1); + + hthis_offset *= BITS_PER_UNIT; + bit_offset += hthis_offset; + bit_offset += tree_low_cst (DECL_FIELD_BIT_OFFSET (field), 1); } else { @@ -925,8 +921,7 @@ get_ref_base_and_extent (tree exp, HOST_WIDE_INT *poffset, if (maxsize != -1 && csize && host_integerp (csize, 1)) { - maxsize = (TREE_INT_CST_LOW (csize) - - TREE_INT_CST_LOW (bit_offset)); + maxsize = (TREE_INT_CST_LOW (csize) - bit_offset); } else maxsize = -1; @@ -941,17 +936,17 @@ get_ref_base_and_extent (tree exp, HOST_WIDE_INT *poffset, tree low_bound = array_ref_low_bound (exp); tree unit_size = array_ref_element_size (exp); - if (! integer_zerop (low_bound)) - index = fold_build2 (MINUS_EXPR, TREE_TYPE (index), - index, low_bound); - index = size_binop (MULT_EXPR, - fold_convert (sizetype, index), unit_size); - if (TREE_CODE (index) == INTEGER_CST) + /* If the resulting bit-offset is constant, track it. */ + if (host_integerp (index, 0) + && host_integerp (low_bound, 0) + && host_integerp (unit_size, 1)) { - index = size_binop (MULT_EXPR, - fold_convert (bitsizetype, index), - bitsize_unit_node); - bit_offset = size_binop (PLUS_EXPR, bit_offset, index); + HOST_WIDE_INT hindex = tree_low_cst (index, 0); + + hindex -= tree_low_cst (low_bound, 0); + hindex *= tree_low_cst (unit_size, 1); + hindex *= BITS_PER_UNIT; + bit_offset += hindex; /* An array ref with a constant index up in the structure hierarchy will constrain the size of any variable array ref @@ -967,8 +962,7 @@ get_ref_base_and_extent (tree exp, HOST_WIDE_INT *poffset, if (maxsize != -1 && asize && host_integerp (asize, 1)) { - maxsize = (TREE_INT_CST_LOW (asize) - - TREE_INT_CST_LOW (bit_offset)); + maxsize = (TREE_INT_CST_LOW (asize) - bit_offset); } else maxsize = -1; @@ -984,8 +978,7 @@ get_ref_base_and_extent (tree exp, HOST_WIDE_INT *poffset, break; case IMAGPART_EXPR: - bit_offset = size_binop (PLUS_EXPR, bit_offset, - bitsize_int (bitsize)); + bit_offset += bitsize; break; case VIEW_CONVERT_EXPR: @@ -1011,14 +1004,14 @@ get_ref_base_and_extent (tree exp, HOST_WIDE_INT *poffset, if (seen_variable_array_ref && maxsize != -1 && host_integerp (TYPE_SIZE (TREE_TYPE (exp)), 1) - && TREE_INT_CST_LOW (bit_offset) + maxsize - == TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (exp)))) + && bit_offset + maxsize + == (signed)TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (exp)))) maxsize = -1; /* ??? Due to negative offsets in ARRAY_REF we can end up with negative bit_offset here. We might want to store a zero offset in this case. */ - *poffset = TREE_INT_CST_LOW (bit_offset); + *poffset = bit_offset; *psize = bitsize; *pmax_size = maxsize;