+2009-11-24 Martin Jambor <mjambor@suse.cz>
+
+ PR tree-optimization/42154
+ * tree-sra.c (struct access): Added comments.
+ (sra_modify_expr): Build references to the old aggregate with
+ build_ref_for_offset instead of reusing access->expr.
+ (load_assign_lhs_subreplacements): Likewise.
+
2009-11-24 Uros Bizjak <ubizjak@gmail.com>
* config/i386/i386.md (add<mode>3_carry): Change insn pattern
HOST_WIDE_INT size;
tree base;
- /* Expression. */
+ /* Expression. It is context dependent so do not use it to create new
+ expressions to access the original aggregate. See PR 42154 for a
+ testcase. */
tree expr;
/* Type. */
tree type;
gcc.c-torture/compile/20011217-1.c. */
if (!is_gimple_reg_type (type))
{
- gimple stmt;
+ tree ref = access->base;
+ bool ok;
+
+ ok = build_ref_for_offset (&ref, TREE_TYPE (ref),
+ access->offset, access->type, false);
+ gcc_assert (ok);
+
if (write)
{
- tree ref = unshare_expr (access->expr);
+ gimple stmt;
+
if (access->grp_partial_lhs)
ref = force_gimple_operand_gsi (gsi, ref, true, NULL_TREE,
false, GSI_NEW_STMT);
}
else
{
+ gimple stmt;
+
if (access->grp_partial_lhs)
repl = force_gimple_operand_gsi (gsi, repl, true, NULL_TREE,
true, GSI_SAME_STMT);
- stmt = gimple_build_assign (unshare_expr (access->expr), repl);
+ stmt = gimple_build_assign (ref, repl);
gsi_insert_before (gsi, stmt, GSI_SAME_STMT);
}
}
}
else
{
- bool repl_found;
-
/* No suitable access on the right hand side, need to load from
the aggregate. See if we have to update it first... */
if (*refreshed == SRA_UDH_NONE)
lhs, old_gsi);
if (*refreshed == SRA_UDH_LEFT)
- rhs = unshare_expr (lacc->expr);
+ {
+ bool repl_found;
+
+ rhs = lacc->base;
+ repl_found = build_ref_for_offset (&rhs, TREE_TYPE (rhs),
+ lacc->offset, lacc->type,
+ false);
+ gcc_assert (repl_found);
+ }
else
{
+ bool repl_found;
+
rhs = top_racc->base;
repl_found = build_ref_for_offset (&rhs,
TREE_TYPE (top_racc->base),