OSDN Git Service

gcc/
[pf3gnuchains/gcc-fork.git] / gcc / tree-sra.c
index 3e510a6..d32bbeb 100644 (file)
@@ -811,7 +811,7 @@ create_access (tree expr, gimple stmt, bool write)
 /* Return true iff TYPE is a RECORD_TYPE with fields that are either of gimple
    register types or (recursively) records with only these two kinds of fields.
    It also returns false if any of these records has a zero-size field as its
-   last field.  */
+   last field or has a bit-field.  */
 
 static bool
 type_consists_of_records_p (tree type)
@@ -827,6 +827,9 @@ type_consists_of_records_p (tree type)
       {
        tree ft = TREE_TYPE (fld);
 
+       if (DECL_BIT_FIELD (fld))
+         return false;
+
        if (!is_gimple_reg_type (ft)
            && !type_consists_of_records_p (ft))
          return false;
@@ -843,10 +846,12 @@ type_consists_of_records_p (tree type)
 /* Create total_scalarization accesses for all scalar type fields in DECL that
    must be of a RECORD_TYPE conforming to type_consists_of_records_p.  BASE
    must be the top-most VAR_DECL representing the variable, OFFSET must be the
-   offset of DECL within BASE.  */
+   offset of DECL within BASE.  REF must be the memory reference expression for
+   the given decl.  */
 
 static void
-completely_scalarize_record (tree base, tree decl, HOST_WIDE_INT offset)
+completely_scalarize_record (tree base, tree decl, HOST_WIDE_INT offset,
+                            tree ref)
 {
   tree fld, decl_type = TREE_TYPE (decl);
 
@@ -855,28 +860,23 @@ completely_scalarize_record (tree base, tree decl, HOST_WIDE_INT offset)
       {
        HOST_WIDE_INT pos = offset + int_bit_position (fld);
        tree ft = TREE_TYPE (fld);
+       tree nref = build3 (COMPONENT_REF, TREE_TYPE (fld), ref, fld,
+                           NULL_TREE);
 
        if (is_gimple_reg_type (ft))
          {
            struct access *access;
            HOST_WIDE_INT size;
-           tree expr;
-           bool ok;
 
            size = tree_low_cst (DECL_SIZE (fld), 1);
-           expr = base;
-           ok = build_ref_for_offset (&expr, TREE_TYPE (base), pos,
-                                      ft, false);
-           gcc_assert (ok);
-
            access = create_access_1 (base, pos, size);
-           access->expr = expr;
+           access->expr = nref;
            access->type = ft;
            access->total_scalarization = 1;
            /* Accesses for intraprocedural SRA can have their stmt NULL.  */
          }
        else
-         completely_scalarize_record (base, fld, pos);
+         completely_scalarize_record (base, fld, pos, nref);
       }
 }
 
@@ -2067,7 +2067,7 @@ analyze_all_variable_accesses (void)
                <= max_total_scalarization_size)
            && type_consists_of_records_p (TREE_TYPE (var)))
          {
-           completely_scalarize_record (var, var, 0);
+           completely_scalarize_record (var, var, 0, var);
            if (dump_file && (dump_flags & TDF_DETAILS))
              {
                fprintf (dump_file, "Will attempt to totally scalarize ");