From: Richard Biener <rguenther@suse.de>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH] Fold RHS when open-coding memcpy
Date: Fri, 10 Jun 2016 11:41:00 -0000 [thread overview]
Message-ID: <alpine.LSU.2.11.1606101340160.13824@t29.fhfr.qr> (raw)
I noticed that we fail to fold the source to a constant if possible.
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.
Richard.
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.
Index: gcc/gimple-fold.c
===================================================================
*** gcc/gimple-fold.c (revision 237286)
--- gcc/gimple-fold.c (working copy)
*************** gimple_fold_builtin_memory_op (gimple_st
*** 1020,1033 ****
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);
}
new_stmt = gimple_build_assign (destvar, srcvar);
gimple_set_vuse (new_stmt, gimple_vuse (stmt));
--- 1020,1039 ----
gimple *new_stmt;
if (is_gimple_reg_type (TREE_TYPE (srcvar)))
{
! 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));
reply other threads:[~2016-06-10 11:41 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.LSU.2.11.1606101340160.13824@t29.fhfr.qr \
--to=rguenther@suse.de \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).