From: Segher Boessenkool <segher@kernel.crashing.org>
To: Jiufu Guo <guojiufu@linux.ibm.com>
Cc: gcc-patches@gcc.gnu.org, dje.gcc@gmail.com, linkw@gcc.gnu.org,
ebotcazou@libertysurf.fr, steven@gcc.gnu.org, rguenther@suse.de,
jeffreyalaw@gmail.com
Subject: Re: [PATCH V3] Use reg mode to move sub blocks for parameters and returns
Date: Thu, 8 Dec 2022 08:58:21 -0600 [thread overview]
Message-ID: <20221208145821.GB25951@gate.crashing.org> (raw)
In-Reply-To: <7ewn72m3v1.fsf@pike.rch.stglabs.ibm.com>
On Thu, Dec 08, 2022 at 09:17:38PM +0800, Jiufu Guo wrote:
> Segher Boessenkool <segher@kernel.crashing.org> writes:
> > On Wed, Dec 07, 2022 at 08:00:08PM +0800, Jiufu Guo wrote:
> >> 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)
> >
> > What is this like if you use [5] instead? Or use an ABI without
> > homogeneous aggregates?
> Thanks for this question! I also tested the cases on different array
> types or different sizes, or mixed field types.
>
> If it is out of the number of registers for passing the param
> or return, it is treated as a mem block.
> For parameter, it is partially passed via registers, and partially
> passing via stack.
> For return, it is returned via a pointer (with one invisible pointer
> parameter). And the <retval> of the function is not with parallel code.
>
> This patch does not cover these cases.
Understood, sure; but my point is, can it degrade code quality in such
cases? I don't see anything in the patch that precludes that.
> >> --- /dev/null
> >> +++ b/gcc/testsuite/gcc.target/powerpc/pr65421-1.c
> >> @@ -0,0 +1,15 @@
> >> +/* PR target/65421 */
> >> +/* { dg-options "-O2" } */
> >> +/* { dg-require-effective-target has_arch_ppc64 } */
> >> +
> >> +typedef struct SA
> >> +{
> >> + double a[2];
> >> + long l;
> >> +} A;
> >> +
> >> +/* std 3 param regs to return slot */
> >> +A ret_arg (A a) {return a;}
> >> +/* { dg-final { scan-assembler-times {\mstd 4,0\(3\)\s} 1 } } */
> >> +/* { dg-final { scan-assembler-times {\mstd 5,8\(3\)\s} 1 } } *
> >> +/* { dg-final { scan-assembler-times {\mstd 6,16\(3\)\s} 1 } } */
> >
> > This is only correct on certain ABIs, probably only ELFv2 even.
> Thanks for point out this!
> This is only correct if the ABI allows this struct to be passed
> through integer registers, and return through the mem block.
And it needs to be in those specific registers / at those specific
offsets as well.
Btw, please leave out the \s?
> In the previous version, I added a requirement on ELFv2. As tested on
> BE environments, this case also pass. So, I deleted the requirement.
BE for ELFv2 also exists, fwiw.
> (While on BE environments, there is another issue: some unnecessary
> memory stores are not deleted.)
Huh. Does that happen with the current compiler as well? Do you have
an example?
> But with more reading of the code 'rs6000_function_arg', as you said,
> I'm not sure if this behavior meets other ABIs (at least, it seems,
> this is not correct on darwin64).
> So, as you said, we may add a requirement on ELFv2; Or leave this
> case there, and add "! target" when hitting failure?
If you do !target the testcase won't test much at all anymore ;-)
> > We certainly can improve the homogeneous aggregates stuff, but please
> > make sure you don't degrade all other stuff? Older, as well as when
> > things are not an homogeneous aggregate, for example too big. Can you
> > please add tests for such cases?
> Sure, thanks! I encounter one issue in this kind of case (large struct)
> on a previous version path.
Perhaps it would be better to have a hook so that every target (and
subtarget) can fine tune exactly when this is done. Then again, perhaps
I worry too much.
Segher
next prev parent reply other threads:[~2022-12-08 14:59 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-07 12:00 Jiufu Guo
2022-12-07 15:23 ` Segher Boessenkool
2022-12-08 13:17 ` Jiufu Guo
2022-12-08 14:58 ` Segher Boessenkool [this message]
2022-12-09 3:46 ` Jiufu Guo
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=20221208145821.GB25951@gate.crashing.org \
--to=segher@kernel.crashing.org \
--cc=dje.gcc@gmail.com \
--cc=ebotcazou@libertysurf.fr \
--cc=gcc-patches@gcc.gnu.org \
--cc=guojiufu@linux.ibm.com \
--cc=jeffreyalaw@gmail.com \
--cc=linkw@gcc.gnu.org \
--cc=rguenther@suse.de \
--cc=steven@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).