OSDN Git Service

2008-06-07 Xinliang David Li <davidxl@google.com>
[pf3gnuchains/gcc-fork.git] / gcc / tree-sra.c
index 752f87d..aea18d5 100644 (file)
@@ -268,6 +268,7 @@ sra_type_can_be_decomposed_p (tree type)
            {
              /* Reject incorrectly represented bit fields.  */
              if (DECL_BIT_FIELD (t)
+                 && INTEGRAL_TYPE_P (TREE_TYPE (t))
                  && (tree_low_cst (DECL_SIZE (t), 1)
                      != TYPE_PRECISION (TREE_TYPE (t))))
                goto fail;
@@ -356,7 +357,7 @@ decl_can_be_decomposed_p (tree var)
   /* HACK: if we decompose a va_list_type_node before inlining, then we'll
      confuse tree-stdarg.c, and we won't be able to figure out which and
      how many arguments are accessed.  This really should be improved in
-     tree-stdarg.c, as the decomposition is truely a win.  This could also
+     tree-stdarg.c, as the decomposition is truly a win.  This could also
      be fixed if the stdarg pass ran early, but this can't be done until
      we've aliasing information early too.  See PR 30791.  */
   if (early_sra
@@ -855,18 +856,28 @@ sra_walk_expr (tree *expr_p, block_stmt_iterator *bsi, bool is_output,
            if (elt)
              elt->is_vector_lhs = true;
          }
+
        /* A bit field reference (access to *multiple* fields simultaneously)
-          is not currently scalarized.  Consider this an access to the
-          complete outer element, to which walk_tree will bring us next.  */
-         
+          is not currently scalarized.  Consider this an access to the full
+          outer element, to which walk_tree will bring us next.  */
        goto use_all;
 
-      case VIEW_CONVERT_EXPR:
       case NOP_EXPR:
-       /* Similarly, a view/nop explicitly wants to look at an object in a
+       /* Similarly, a nop explicitly wants to look at an object in a
           type other than the one we've scalarized.  */
        goto use_all;
 
+      case VIEW_CONVERT_EXPR:
+       /* Likewise for a view conversion, but with an additional twist:
+          it can be on the LHS and, in this case, an access to the full
+          outer element would mean a killing def.  So we need to punt
+          if we haven't already a full access to the current element,
+          because we cannot pretend to have a killing def if we only
+          have a partial access at some level.  */
+       if (is_output && !use_all_p && inner != expr)
+         disable_scalarization = true;
+       goto use_all;
+
       case WITH_SIZE_EXPR:
        /* This is a transparent wrapper.  The entire inner expression really
           is being used.  */
@@ -1462,6 +1473,10 @@ try_instantiate_multiple_fields (struct sra_elt *elt, tree f)
   tree type, var;
   struct sra_elt *block;
 
+  /* Point fields are typically best handled as standalone entities.  */
+  if (POINTER_TYPE_P (TREE_TYPE (f)))
+    return f;
+    
   if (!is_sra_scalar_type (TREE_TYPE (f))
       || !host_integerp (DECL_FIELD_OFFSET (f), 1)
       || !host_integerp (DECL_FIELD_BIT_OFFSET (f), 1)
@@ -2061,7 +2076,7 @@ generate_one_element_ref (struct sra_elt *elt, tree base)
       {
        tree field = elt->element;
 
-       /* We can't test elt->in_bitfld_blk here because, when this is
+       /* We can't test elt->in_bitfld_block here because, when this is
           called from instantiate_element, we haven't set this field
           yet.  */
        if (TREE_CODE (field) == BIT_FIELD_REF)
@@ -2147,7 +2162,7 @@ sra_build_assignment (tree dst, tree src)
       var = TREE_OPERAND (src, 0);
       width = TREE_OPERAND (src, 1);
       /* The offset needs to be adjusted to a right shift quantity
-        depending on the endianess.  */
+        depending on the endianness.  */
       if (BYTES_BIG_ENDIAN)
        {
          tree tmp = size_binop (PLUS_EXPR, width, TREE_OPERAND (src, 2));