public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Christophe LYON <christophe.lyon@foss.st.com>
To: <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] aarch64: Improve size heuristic for cpymem expansion
Date: Thu, 30 Sep 2021 15:51:06 +0200	[thread overview]
Message-ID: <94aad3b0-7455-931e-2484-adcf2fcc1051@foss.st.com> (raw)
In-Reply-To: <PAXPR08MB6926327FD9852F84C7D4AF6593A99@PAXPR08MB6926.eurprd08.prod.outlook.com>


On 29/09/2021 12:20, Kyrylo Tkachov via Gcc-patches wrote:
> Hi all,
>
> Similar to my previous patch for setmem this one does the same for the cpymem expansion.
> We count the number of ops emitted and compare it against the alternative of just calling
> the library function when optimising for size.
> For the code:
> void
> cpy_127 (char *out, char *in)
> {
>    __builtin_memcpy (out, in, 127);
> }
>
> void
> cpy_128 (char *out, char *in)
> {
>    __builtin_memcpy (out, in, 128);
> }
>
> we now emit a call to memcpy (with an extra MOV-immediate instruction for the size) instead of:
> cpy_127(char*, char*):
>          ldp     q0, q1, [x1]
>          stp     q0, q1, [x0]
>          ldp     q0, q1, [x1, 32]
>          stp     q0, q1, [x0, 32]
>          ldp     q0, q1, [x1, 64]
>          stp     q0, q1, [x0, 64]
>          ldr     q0, [x1, 96]
>          str     q0, [x0, 96]
>          ldr     q0, [x1, 111]
>          str     q0, [x0, 111]
>          ret
> cpy_128(char*, char*):
>          ldp     q0, q1, [x1]
>          stp     q0, q1, [x0]
>          ldp     q0, q1, [x1, 32]
>          stp     q0, q1, [x0, 32]
>          ldp     q0, q1, [x1, 64]
>          stp     q0, q1, [x0, 64]
>          ldp     q0, q1, [x1, 96]
>          stp     q0, q1, [x0, 96]
>          ret
>
> which is a clear code size win. Speed optimisation heuristics remain unchanged.
> Bootstrapped and tested on aarch64-none-linux-gnu.
> Pushing to trunk.
>
> Thanks,
> Kyrill
>
> 2021-09-29  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
>
> 	* config/aarch64/aarch64.c (aarch64_expand_cpymem): Count number of
> 	emitted operations and adjust heuristic for code size.
>      
> 2021-09-29  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
>
> 	* gcc.target/aarch64/cpymem-size.c: New test.


Hi Kyrill,

Just to mention that the new test fails with -mabi=ilp32...


Thanks,


Christophe




  reply	other threads:[~2021-09-30 13:51 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-29 10:20 Kyrylo Tkachov
2021-09-30 13:51 ` Christophe LYON [this message]
2021-10-01 11:19   ` Kyrylo Tkachov

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=94aad3b0-7455-931e-2484-adcf2fcc1051@foss.st.com \
    --to=christophe.lyon@foss.st.com \
    --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).