diff options
author | Richard Biener <rguenther@suse.de> | 2016-06-10 11:44:47 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2016-06-10 11:44:47 +0000 |
commit | 921b13d09390034dea6d11ee47471efcca865ba6 (patch) | |
tree | 5aa058652db38b6b331b933f9da2106f041395ab | |
parent | 2cfab6c0f78dbb079737861ab7346420642d1b47 (diff) | |
download | gcc-921b13d09390034dea6d11ee47471efcca865ba6.zip gcc-921b13d09390034dea6d11ee47471efcca865ba6.tar.gz gcc-921b13d09390034dea6d11ee47471efcca865ba6.tar.bz2 |
gimple-fold.c (gimple_fold_builtin_memory_op): Make sure to fold the RHS to a constant if possible.
2016-06-10 Richard Biener <rguenther@suse.de>
* gimple-fold.c (gimple_fold_builtin_memory_op): Make sure
to fold the RHS to a constant if possible.
From-SVN: r237301
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/gimple-fold.c | 22 |
2 files changed, 19 insertions, 8 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9cab311..5038f75 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2016-06-10 Richard Biener <rguenther@suse.de> + + * gimple-fold.c (gimple_fold_builtin_memory_op): Make sure + to fold the RHS to a constant if possible. + 2016-06-10 Thomas Schwinge <thomas@codesourcery.com> PR middle-end/71373 diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c index 600aa72..885367e 100644 --- a/gcc/gimple-fold.c +++ b/gcc/gimple-fold.c @@ -1020,14 +1020,20 @@ gimple_fold_builtin_memory_op (gimple_stmt_iterator *gsi, gimple *new_stmt; if (is_gimple_reg_type (TREE_TYPE (srcvar))) { - new_stmt = gimple_build_assign (NULL_TREE, srcvar); - if (gimple_in_ssa_p (cfun)) - srcvar = make_ssa_name (TREE_TYPE (srcvar), new_stmt); - else - srcvar = create_tmp_reg (TREE_TYPE (srcvar)); - gimple_assign_set_lhs (new_stmt, srcvar); - gimple_set_vuse (new_stmt, gimple_vuse (stmt)); - gsi_insert_before (gsi, new_stmt, GSI_SAME_STMT); + tree tem = fold_const_aggregate_ref (srcvar); + if (tem) + srcvar = tem; + if (! is_gimple_min_invariant (srcvar)) + { + new_stmt = gimple_build_assign (NULL_TREE, srcvar); + if (gimple_in_ssa_p (cfun)) + srcvar = make_ssa_name (TREE_TYPE (srcvar), new_stmt); + else + srcvar = create_tmp_reg (TREE_TYPE (srcvar)); + gimple_assign_set_lhs (new_stmt, srcvar); + gimple_set_vuse (new_stmt, gimple_vuse (stmt)); + gsi_insert_before (gsi, new_stmt, GSI_SAME_STMT); + } } new_stmt = gimple_build_assign (destvar, srcvar); gimple_set_vuse (new_stmt, gimple_vuse (stmt)); |