summaryrefslogtreecommitdiff
path: root/gcc/tree-sra.c
diff options
context:
space:
mode:
authorjamborm <jamborm@138bc75d-0d04-0410-961f-82ee72b054a4>2009-12-01 17:39:44 +0000
committerjamborm <jamborm@138bc75d-0d04-0410-961f-82ee72b054a4>2009-12-01 17:39:44 +0000
commitc77fa5484e7c9746a0992b3db5a69a2fed5ef8d2 (patch)
tree53d7b9d714ee4065887856ae83a6c37f3a1a9412 /gcc/tree-sra.c
parentedbb328f08335dc95672cc24f135acd556c195cd (diff)
downloadgcc-c77fa5484e7c9746a0992b3db5a69a2fed5ef8d2.tar.gz
2009-12-01 Martin Jambor <mjambor@suse.cz>
PR tree-optimization/42237 * tree-sra.c (sra_ipa_modify_assign): Split gimple_reg_type assignments in between references into two. * testsuite/gcc.c-torture/compile/pr42237.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@154874 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-sra.c')
-rw-r--r--gcc/tree-sra.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c
index 2c75838835a..a6a1a90d757 100644
--- a/gcc/tree-sra.c
+++ b/gcc/tree-sra.c
@@ -3707,12 +3707,22 @@ sra_ipa_modify_assign (gimple *stmt_ptr, gimple_stmt_iterator *gsi, void *data)
any |= sra_ipa_modify_expr (lhs_p, gsi, true, data);
if (any)
{
+ tree new_rhs = NULL_TREE;
+
if (!useless_type_conversion_p (TREE_TYPE (*lhs_p), TREE_TYPE (*rhs_p)))
+ new_rhs = fold_build1_loc (gimple_location (stmt), VIEW_CONVERT_EXPR,
+ TREE_TYPE (*lhs_p), *rhs_p);
+ else if (REFERENCE_CLASS_P (*rhs_p)
+ && is_gimple_reg_type (TREE_TYPE (*lhs_p))
+ && !is_gimple_reg (*lhs_p))
+ /* This can happen when an assignment in between two single field
+ structures is turned into an assignment in between two pointers to
+ scalars (PR 42237). */
+ new_rhs = *rhs_p;
+
+ if (new_rhs)
{
- location_t loc = gimple_location (stmt);
- tree vce = fold_build1_loc (loc, VIEW_CONVERT_EXPR,
- TREE_TYPE (*lhs_p), *rhs_p);
- tree tmp = force_gimple_operand_gsi (gsi, vce, true, NULL_TREE,
+ tree tmp = force_gimple_operand_gsi (gsi, new_rhs, true, NULL_TREE,
true, GSI_SAME_STMT);
gimple_assign_set_rhs_from_tree (gsi, tmp);