From: Jeff Law <jeffreyalaw@gmail.com>
To: Jiufu Guo <guojiufu@linux.ibm.com>, gcc-patches@gcc.gnu.org
Cc: rguenther@suse.de, segher@kernel.crashing.org, dje.gcc@gmail.com,
linkw@gcc.gnu.org, meissner@linux.ibm.com
Subject: Re: [PATCH V5] Use reg mode to move sub blocks for parameters and returns
Date: Sun, 30 Apr 2023 13:00:51 -0600 [thread overview]
Message-ID: <0221bead-5d08-cb56-e620-642825c1abc3@gmail.com> (raw)
In-Reply-To: <20230317033952.1549050-1-guojiufu@linux.ibm.com>
On 3/16/23 21:39, Jiufu Guo wrote:
> Hi,
>
> When assigning a parameter to a variable, or assigning a variable to
> return value with struct type, and the parameter/return is passed
> through registers.
> For this kind of case, it would be better to use the nature mode of
> the registers to move the content for the assignment.
>
> As the example code (like code in PR65421):
>
> typedef struct SA {double a[3];} A;
> A ret_arg_pt (A *a) {return *a;} // on ppc64le, expect only 3 lfd(s)
> A ret_arg (A a) {return a;} // just empty fun body
> void st_arg (A a, A *p) {*p = a;} //only 3 stfd(s)
>
> Comparing with previous version:
> https://gcc.gnu.org/pipermail/gcc-patches/2023-January/609394.html
> This version refine code to eliminated reductant code in the sub
> routine "move_sub_blocks".
>
> Bootstrap and regtest pass on ppc64{,le}.
> Is this ok for trunk?
>
> BR,
> Jeff (Jiufu)
>
> PR target/65421
>
> gcc/ChangeLog:
>
> * cfgexpand.cc (expand_used_vars): Update to mark DECL_USEDBY_RETURN_P
> for returns.
> * expr.cc (move_sub_blocks): New function.
> (expand_assignment): Update assignment code about returns/parameters.
> * function.cc (assign_parm_setup_block): Update to mark
> DECL_REGS_TO_STACK_P for parameter.
> * tree-core.h (struct tree_decl_common): Add comment.
> * tree.h (DECL_USEDBY_RETURN_P): New define.
> (DECL_REGS_TO_STACK_P): New define.
>
> gcc/testsuite/ChangeLog:
>
> * gcc.target/powerpc/pr65421-1.c: New test.
> * gcc.target/powerpc/pr65421.c: New test.
>
> ---
> gcc/cfgexpand.cc | 14 +++++
> gcc/expr.cc | 61 ++++++++++++++++++++
> gcc/function.cc | 3 +
> gcc/tree-core.h | 4 +-
> gcc/tree.h | 9 +++
> gcc/testsuite/gcc.target/powerpc/pr65421-1.c | 6 ++
> gcc/testsuite/gcc.target/powerpc/pr65421.c | 33 +++++++++++
> 7 files changed, 129 insertions(+), 1 deletion(-)
> create mode 100644 gcc/testsuite/gcc.target/powerpc/pr65421-1.c
> create mode 100644 gcc/testsuite/gcc.target/powerpc/pr65421.c
>
> diff --git a/gcc/expr.cc b/gcc/expr.cc
> index 15be1c8db99..97a7be9542e 100644
> --- a/gcc/expr.cc
> +++ b/gcc/expr.cc
> @@ -5559,6 +5559,41 @@ mem_ref_refers_to_non_mem_p (tree ref)
> return non_mem_decl_p (base);
> }
>
> +/* Sub routine of expand_assignment, invoked when assigning from a
> + parameter or assigning to a return val on struct type which may
> + be passed through registers. The mode of register is used to
> + move the content for the assignment.
> +
> + This routine generates code for expression FROM which is BLKmode,
> + and move the generated content to TO_RTX by su-blocks in SUB_MODE. */
> +
> +static void
> +move_sub_blocks (rtx to_rtx, tree from, machine_mode sub_mode)
> +{
> + gcc_assert (MEM_P (to_rtx));
> +
> + HOST_WIDE_INT size = MEM_SIZE (to_rtx).to_constant ();
Consider the case of a BLKmode return value. Isn't TO_RTX in this case
a BLKmode object?
It looks pretty good at this point.
jeff
next prev parent reply other threads:[~2023-04-30 19:00 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-17 3:39 Jiufu Guo
2023-04-30 19:00 ` Jeff Law [this message]
2023-05-04 5:49 ` guojiufu
2023-05-05 23:37 ` Jeff Law
2023-05-09 13:43 ` Jiufu Guo
2023-06-04 16:59 ` Jeff Law
2023-06-07 1:21 ` guojiufu
2023-05-01 15:52 ` Segher Boessenkool
2023-05-04 5:55 ` guojiufu
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=0221bead-5d08-cb56-e620-642825c1abc3@gmail.com \
--to=jeffreyalaw@gmail.com \
--cc=dje.gcc@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=guojiufu@linux.ibm.com \
--cc=linkw@gcc.gnu.org \
--cc=meissner@linux.ibm.com \
--cc=rguenther@suse.de \
--cc=segher@kernel.crashing.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).