summaryrefslogtreecommitdiff
path: root/gcc/tree-sra.c
diff options
context:
space:
mode:
authorrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>2010-01-22 18:52:01 +0000
committerrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>2010-01-22 18:52:01 +0000
commitfd9864aa3d1e572402cf4fe7e6c3e6cf39209401 (patch)
tree3305726401c185237a4df96747f19c0599fc7716 /gcc/tree-sra.c
parent2171e626156706d8af6f9d3d4c2fc86f7eba09bd (diff)
downloadgcc-fd9864aa3d1e572402cf4fe7e6c3e6cf39209401.tar.gz
PR tree-opt/42833
* tree-sra.c (sra_modify_assign): Delay re-gimplification of the RHS until after generate_subtree_copies has insertted its code before the current statement. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@156176 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-sra.c')
-rw-r--r--gcc/tree-sra.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c
index 07658bddae9..79c5c76c5e1 100644
--- a/gcc/tree-sra.c
+++ b/gcc/tree-sra.c
@@ -2533,6 +2533,7 @@ sra_modify_assign (gimple *stmt, gimple_stmt_iterator *gsi,
bool modify_this_stmt = false;
bool force_gimple_rhs = false;
location_t loc = gimple_location (*stmt);
+ gimple_stmt_iterator orig_gsi = *gsi;
if (!gimple_assign_single_p (*stmt))
return SRA_SA_NONE;
@@ -2611,15 +2612,6 @@ sra_modify_assign (gimple *stmt, gimple_stmt_iterator *gsi,
force_gimple_rhs = true;
}
}
-
- if (force_gimple_rhs)
- rhs = force_gimple_operand_gsi (gsi, rhs, true, NULL_TREE,
- true, GSI_SAME_STMT);
- if (gimple_assign_rhs1 (*stmt) != rhs)
- {
- gimple_assign_set_rhs_from_tree (gsi, rhs);
- gcc_assert (*stmt == gsi_stmt (*gsi));
- }
}
/* From this point on, the function deals with assignments in between
@@ -2721,6 +2713,18 @@ sra_modify_assign (gimple *stmt, gimple_stmt_iterator *gsi,
0, 0, gsi, true, true);
}
}
+
+ /* This gimplification must be done after generate_subtree_copies, lest we
+ insert the subtree copies in the middle of the gimplified sequence. */
+ if (force_gimple_rhs)
+ rhs = force_gimple_operand_gsi (&orig_gsi, rhs, true, NULL_TREE,
+ true, GSI_SAME_STMT);
+ if (gimple_assign_rhs1 (*stmt) != rhs)
+ {
+ gimple_assign_set_rhs_from_tree (&orig_gsi, rhs);
+ gcc_assert (*stmt == gsi_stmt (orig_gsi));
+ }
+
return modify_this_stmt ? SRA_SA_PROCESSED : SRA_SA_NONE;
}