Hi, On Thu, May 26, 2011 at 03:43:45PM +0200, Michael Matz wrote: > Index: tree-sra.c > =================================================================== > --- tree-sra.c.orig 2011-05-26 14:15:01.000000000 +0200 > +++ tree-sra.c 2011-05-26 14:15:41.000000000 +0200 > @@ -1041,6 +1041,11 @@ build_accesses_from_assign (gimple stmt) > if (disqualify_ops_if_throwing_stmt (stmt, lhs, rhs)) > return false; > > + /* Scope clobbers don't influence scalarization. */ > + if (TREE_CODE (rhs) == CONSTRUCTOR > + && TREE_THIS_VOLATILE (rhs)) > + return false; > + > racc = build_access_from_expr_1 (rhs, stmt, false); > lacc = build_access_from_expr_1 (lhs, stmt, true);
I assume DSE does not remove the stores as that would defeat the purpose of the patch. If after optimizations such as SRA, these special stores are the only statements accessing the variable, will the variable still remain in the function potentially causing an unnecessary stack frame setup? If so, then SRA would have to delete these statements in its modification phase if it has removed all other accesses to the aggregate. This is something I can do as a followup, of course. Thanks, Martin > > Index: tree-ssa-dce.c > =================================================================== > --- tree-ssa-dce.c.orig 2011-05-26 14:15:01.000000000 +0200 > +++ tree-ssa-dce.c 2011-05-26 14:15:41.000000000 +0200 > @@ -846,19 +846,17 @@ propagate_necessity (struct edge_list *e > else if (gimple_assign_single_p (stmt)) > { > tree rhs; > - bool rhs_aliased = false; > /* If this is a load mark things necessary. */ > rhs = gimple_assign_rhs1 (stmt); > if (TREE_CODE (rhs) != SSA_NAME > - && !is_gimple_min_invariant (rhs)) > + && !is_gimple_min_invariant (rhs) > + && TREE_CODE (rhs) != CONSTRUCTOR) > { > if (!ref_may_be_aliased (rhs)) > mark_aliased_reaching_defs_necessary (stmt, rhs); > else > - rhs_aliased = true; > + mark_all_reaching_defs_necessary (stmt); > } > - if (rhs_aliased) > - mark_all_reaching_defs_necessary (stmt); > } > else if (gimple_code (stmt) == GIMPLE_RETURN) > { > @@ -866,7 +864,8 @@ propagate_necessity (struct edge_list *e > /* A return statement may perform a load. */ > if (rhs > && TREE_CODE (rhs) != SSA_NAME > - && !is_gimple_min_invariant (rhs)) > + && !is_gimple_min_invariant (rhs) > + && TREE_CODE (rhs) != CONSTRUCTOR) > { > if (!ref_may_be_aliased (rhs)) > mark_aliased_reaching_defs_necessary (stmt, rhs); > @@ -884,6 +883,7 @@ propagate_necessity (struct edge_list *e > tree op = TREE_VALUE (gimple_asm_input_op (stmt, i)); > if (TREE_CODE (op) != SSA_NAME > && !is_gimple_min_invariant (op) > + && TREE_CODE (op) != CONSTRUCTOR > && !ref_may_be_aliased (op)) > mark_aliased_reaching_defs_necessary (stmt, op); > } > Index: gimple.c > =================================================================== > --- gimple.c.orig 2011-05-26 14:15:01.000000000 +0200 > +++ gimple.c 2011-05-26 14:15:41.000000000 +0200 > @@ -1425,7 +1425,9 @@ walk_gimple_op (gimple stmt, walk_tree_f > { > /* If the RHS has more than 1 operand, it is not appropriate > for the memory. */ > - wi->val_only = !is_gimple_mem_rhs (gimple_assign_rhs1 (stmt)) > + wi->val_only = !(is_gimple_mem_rhs (gimple_assign_rhs1 (stmt)) > + || TREE_CODE (gimple_assign_rhs1 (stmt)) > + == CONSTRUCTOR) > || !gimple_assign_single_p (stmt); > wi->is_lhs = true; > } > Index: tree-ssa-structalias.c > =================================================================== > --- tree-ssa-structalias.c.orig 2011-05-26 14:15:01.000000000 +0200 > +++ tree-ssa-structalias.c 2011-05-26 14:15:41.000000000 +0200 > @@ -4355,7 +4355,12 @@ find_func_aliases (gimple origt) > tree lhsop = gimple_assign_lhs (t); > tree rhsop = (gimple_num_ops (t) == 2) ? gimple_assign_rhs1 (t) : NULL; > > - if (rhsop && AGGREGATE_TYPE_P (TREE_TYPE (lhsop))) > + if (rhsop && TREE_CODE (rhsop) == CONSTRUCTOR > + && TREE_THIS_VOLATILE (rhsop)) > + /* Ignore clobbers, they don't actually store anything into > + the LHS. */ > + ; > + else if (rhsop && AGGREGATE_TYPE_P (TREE_TYPE (lhsop))) > do_structure_copy (lhsop, rhsop); > else > { > Index: tree-ssa-operands.c > =================================================================== > --- tree-ssa-operands.c.orig 2011-05-26 14:15:01.000000000 +0200 > +++ tree-ssa-operands.c 2011-05-26 14:15:41.000000000 +0200 > @@ -955,6 +955,9 @@ get_expr_operands (gimple stmt, tree *ex > constructor_elt *ce; > unsigned HOST_WIDE_INT idx; > > + if (TREE_THIS_VOLATILE (expr)) > + gimple_set_has_volatile_ops (stmt, true); > + > for (idx = 0; > VEC_iterate (constructor_elt, CONSTRUCTOR_ELTS (expr), idx, ce); > idx++) > Index: tree-ssa-sccvn.c > =================================================================== > --- tree-ssa-sccvn.c.orig 2011-05-26 14:15:39.000000000 +0200 > +++ tree-ssa-sccvn.c 2011-05-26 14:15:41.000000000 +0200 > @@ -1356,6 +1356,7 @@ vn_reference_lookup_3 (ao_ref *ref, tree > else if (is_gimple_reg_type (vr->type) > && gimple_assign_single_p (def_stmt) > && gimple_assign_rhs_code (def_stmt) == CONSTRUCTOR > + && !TREE_THIS_VOLATILE (gimple_assign_rhs1 (def_stmt)) > && CONSTRUCTOR_NELTS (gimple_assign_rhs1 (def_stmt)) == 0) > { > tree base2;