diff options
author | jamborm <jamborm@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-11-24 10:56:14 +0000 |
---|---|---|
committer | jamborm <jamborm@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-11-24 10:56:14 +0000 |
commit | fa30ba2420a52b03807239d6d3d9d61f81e34bd6 (patch) | |
tree | 0794dd3cad6d264dc0489fcc003758e493444d8f /gcc/tree-sra.c | |
parent | ffe221be5de13e10d034dfec9a01b44aa96ea8b3 (diff) | |
download | gcc-fa30ba2420a52b03807239d6d3d9d61f81e34bd6.tar.gz |
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.
* testsuite/gcc.c-torture/execute/pr42154.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@154493 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-sra.c')
-rw-r--r-- | gcc/tree-sra.c | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c index fe82d9851be..52036851587 100644 --- a/gcc/tree-sra.c +++ b/gcc/tree-sra.c @@ -125,7 +125,9 @@ struct access 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; @@ -2113,10 +2115,17 @@ sra_modify_expr (tree *expr, gimple_stmt_iterator *gsi, bool write, 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); @@ -2125,10 +2134,12 @@ sra_modify_expr (tree *expr, gimple_stmt_iterator *gsi, bool write, } 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); } } @@ -2227,8 +2238,6 @@ load_assign_lhs_subreplacements (struct access *lacc, struct access *top_racc, } 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) @@ -2236,9 +2245,19 @@ load_assign_lhs_subreplacements (struct access *lacc, struct access *top_racc, 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), |