OSDN Git Service

gcc/
[pf3gnuchains/gcc-fork.git] / gcc / tree-sra.c
index 85217ec..3689b69 100644 (file)
@@ -881,8 +881,7 @@ sra_walk_expr (tree *expr_p, gimple_stmt_iterator *gsi, bool is_output,
           outer element, to which walk_tree will bring us next.  */
        goto use_all;
 
-      case NOP_EXPR:
-      case CONVERT_EXPR:
+      CASE_CONVERT:
        /* Similarly, a nop explicitly wants to look at an object in a
           type other than the one we've scalarized.  */
        goto use_all;
@@ -1903,10 +1902,10 @@ decide_block_copy (struct sra_elt *elt)
             sensible default.  */
          max_size = SRA_MAX_STRUCTURE_SIZE
            ? SRA_MAX_STRUCTURE_SIZE
-           : MOVE_RATIO * UNITS_PER_WORD;
+           : MOVE_RATIO (optimize_function_for_speed_p (cfun)) * UNITS_PER_WORD;
          max_count = SRA_MAX_STRUCTURE_COUNT
            ? SRA_MAX_STRUCTURE_COUNT
-           : MOVE_RATIO;
+           : MOVE_RATIO (optimize_function_for_speed_p (cfun));
 
          full_size = tree_low_cst (size_tree, 1);
          full_count = count_type_elements (elt->type, false);
@@ -2145,7 +2144,7 @@ static gimple_seq
 sra_build_assignment (tree dst, tree src)
 {
   gimple stmt;
-  gimple_seq seq = NULL;
+  gimple_seq seq = NULL, seq2 = NULL;
   /* Turning BIT_FIELD_REFs into bit operations enables other passes
      to do a much better job at optimizing the code.
      From dst = BIT_FIELD_REF <var, sz, off> we produce
@@ -2309,6 +2308,14 @@ sra_build_assignment (tree dst, tree src)
           && !useless_type_conversion_p (TREE_TYPE (dst), TREE_TYPE (src)))
     src = fold_convert (TREE_TYPE (dst), src);
 
+  /* ???  Only call the gimplifier if we need to.  Otherwise we may 
+     end up substituting with DECL_VALUE_EXPR - see PR37380.  */
+  if (!handled_component_p (src)
+      && !SSA_VAR_P (src))
+    {
+      src = force_gimple_operand (src, &seq2, false, NULL_TREE);
+      gimple_seq_add_seq (&seq, seq2);
+    }
   stmt = gimple_build_assign (dst, src);
   gimple_seq_add_stmt (&seq, stmt);
   return seq;
@@ -2598,8 +2605,7 @@ generate_copy_inout (struct sra_elt *elt, bool copy_out, tree expr,
 
       t = build2 (COMPLEX_EXPR, elt->type, r, i);
       tmp_seq = sra_build_bf_assignment (expr, t);
-      gcc_assert (gimple_seq_singleton_p (tmp_seq));
-      SSA_NAME_DEF_STMT (expr) = gimple_seq_first_stmt (tmp_seq);
+      SSA_NAME_DEF_STMT (expr) = gimple_seq_last_stmt (tmp_seq);
       gimple_seq_add_seq (seq_p, tmp_seq);
     }
   else if (elt->replacement)