public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <richard.guenther@gmail.com>
To: Richard Earnshaw <rearnsha@arm.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH 3/3] gimple: allow more folding of memcpy [PR102125]
Date: Mon, 6 Sep 2021 12:51:33 +0200	[thread overview]
Message-ID: <CAFiYyc1iGcphaY24q1RG1ycSdV3+RN-V8NQUYOvYB6sFUOL+Ag@mail.gmail.com> (raw)
In-Reply-To: <20210906104018.2697413-4-rearnsha@arm.com>

On Mon, Sep 6, 2021 at 12:40 PM Richard Earnshaw <rearnsha@arm.com> wrote:
>
>
> The current restriction on folding memcpy to a single element of size
> MOVE_MAX is excessively cautious on most machines and limits some
> significant further optimizations.  So relax the restriction provided
> the copy size does not exceed MOVE_MAX * MOVE_RATIO and that a SET
> insn exists for moving the value into machine registers.
>
> Note that there were already checks in place for having misaligned
> move operations when one or more of the operands were unaligned.
>
> On Arm this now permits optimizing
>
> uint64_t bar64(const uint8_t *rData1)
> {
>     uint64_t buffer;
>     memcpy(&buffer, rData1, sizeof(buffer));
>     return buffer;
> }
>
> from
>         ldr     r2, [r0]        @ unaligned
>         sub     sp, sp, #8
>         ldr     r3, [r0, #4]    @ unaligned
>         strd    r2, [sp]
>         ldrd    r0, [sp]
>         add     sp, sp, #8
>
> to
>         mov     r3, r0
>         ldr     r0, [r0]        @ unaligned
>         ldr     r1, [r3, #4]    @ unaligned
>
> PR target/102125 - (ARM Cortex-M3 and newer) missed optimization. memcpy not needed operations

OK.

Thanks,
Richard.

> gcc/ChangeLog:
>
>         PR target/102125
>         * gimple-fold.c (gimple_fold_builtin_memory_op): Allow folding
>         memcpy if the size is not more than MOVE_MAX * MOVE_RATIO.
> ---
>  gcc/gimple-fold.c | 16 +++++++++++-----
>  1 file changed, 11 insertions(+), 5 deletions(-)
>

      reply	other threads:[~2021-09-06 10:51 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-06 10:40 [PATCH 0/3] lower more cases " Richard Earnshaw
2021-09-06 10:40 ` [PATCH 1/3] rtl: allow forming subregs of already unaligned mems [PR102125] Richard Earnshaw
2021-09-06 10:58   ` Richard Biener
2021-09-06 11:08     ` Richard Earnshaw
2021-09-06 11:13       ` Richard Biener
2021-09-06 11:23         ` Richard Earnshaw
2021-09-06 12:01           ` Richard Biener
2021-09-06 10:40 ` [PATCH 2/3] arm: expand handling of movmisalign for DImode [PR102125] Richard Earnshaw
2021-09-06 10:40 ` [PATCH 3/3] gimple: allow more folding of memcpy [PR102125] Richard Earnshaw
2021-09-06 10:51   ` Richard Biener [this message]

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=CAFiYyc1iGcphaY24q1RG1ycSdV3+RN-V8NQUYOvYB6sFUOL+Ag@mail.gmail.com \
    --to=richard.guenther@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=rearnsha@arm.com \
    /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).