From: Richard Biener Date: Fri, 10 Jun 2016 11:44:47 +0000 (+0000) Subject: gimple-fold.c (gimple_fold_builtin_memory_op): Make sure to fold the RHS to a constan... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=921b13d09390034dea6d11ee47471efcca865ba6;p=gcc.git gimple-fold.c (gimple_fold_builtin_memory_op): Make sure to fold the RHS to a constant if possible. 2016-06-10 Richard Biener * gimple-fold.c (gimple_fold_builtin_memory_op): Make sure to fold the RHS to a constant if possible. From-SVN: r237301 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9cab3118d65..5038f751ae3 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2016-06-10 Richard Biener + + * gimple-fold.c (gimple_fold_builtin_memory_op): Make sure + to fold the RHS to a constant if possible. + 2016-06-10 Thomas Schwinge PR middle-end/71373 diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c index 600aa72f217..885367e9114 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));