tree-dfa.c (get_ref_base_and_extent): Replace bit_offset and computations with it...
authorRichard Guenther <rguenther@suse.de>
Tue, 27 Mar 2007 15:40:09 +0000 (15:40 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 27 Mar 2007 15:40:09 +0000 (15:40 +0000)
2007-03-27  Richard Guenther  <rguenther@suse.de>

* 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
gcc/tree-dfa.c

index 1f5a44c8f47cd848b4d6512b8c40a5cba0d0b362..7600b6e05f173b1e08f5597d9d2d13b155f353f7 100644 (file)
@@ -1,3 +1,8 @@
+2007-03-27  Richard Guenther  <rguenther@suse.de>
+
+       * 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  <mrs@apple.com>
 
        * config/rs6000/darwin.h (DARWIN_MINVERSION_SPEC): Add
index a1200eb4ebd1e996627108628f6d3f4de54b2136..b23c531cadc3934071e60c64dc29ec1750c4395f 100644 (file)
@@ -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;