public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Cristian Rodríguez" <crrodriguez@opensuse.org>
To: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
Cc: "Alejandro Colomar (man-pages)" <alx.manpages@gmail.com>,
	GNU C Library <libc-alpha@sourceware.org>,
	 "gcc@gcc.gnu.org" <gcc@gcc.gnu.org>
Subject: Re: Missing optimization: mempcpy(3) vs memcpy(3)
Date: Mon, 12 Dec 2022 11:57:36 -0300	[thread overview]
Message-ID: <CAPBLoAcL=5bZaQ_XvoNJEtHBeChNrkXb2orPMwYXEErb6Wg5Kg@mail.gmail.com> (raw)
In-Reply-To: <PAWPR08MB898243076FBFBF6C7E919E4183E29@PAWPR08MB8982.eurprd08.prod.outlook.com>

On Mon, Dec 12, 2022 at 11:35 AM Wilco Dijkstra via Libc-alpha
<libc-alpha@sourceware.org> wrote:
>
> Hi,
>
> I don't believe there is a missing optimization here: compilers expand mempcpy
> by default into memcpy since that is the standard library call. That means even
> if your source code contains mempcpy, there will never be any calls to mempcpy.
>
> The reason is obvious: most targets support optimized memcpy in the C library
> while very few optimize mempcpy. The same is true for bzero, bcmp and bcopy.
>
> Targets can do it differently, IIRC x86 is the only target that emits calls both to
> memcpy and mempcpy.

yeah, x86_64 at least uses both, but I think open coded mempcpy needs
to be transformed into a library call anyway.

Other optimizations that are actually missing are:

-  the cases where of snprintf %s could become memccpy

- open coded memccpy could also be turned into library calls.

  reply	other threads:[~2022-12-12 14:57 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-12 14:34 Wilco Dijkstra
2022-12-12 14:57 ` Cristian Rodríguez [this message]
  -- strict thread matches above, loose matches on Subject: below --
2022-12-09 17:11 Alejandro Colomar
2022-12-12 13:37 ` Martin Liška
2022-12-12 13:44   ` Alejandro Colomar
2022-12-12 13:56     ` Jakub Jelinek
2022-12-12 14:05       ` Alejandro Colomar
2022-12-12 14:48         ` Jonathan Wakely
2022-12-12 14:53           ` Jakub Jelinek
2022-12-12 15:56             ` Alejandro Colomar
2022-12-12 16:09               ` Jakub Jelinek
2022-12-12 17:15                 ` Alejandro Colomar
2022-12-12 17:42                 ` Jonathan Wakely

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='CAPBLoAcL=5bZaQ_XvoNJEtHBeChNrkXb2orPMwYXEErb6Wg5Kg@mail.gmail.com' \
    --to=crrodriguez@opensuse.org \
    --cc=Wilco.Dijkstra@arm.com \
    --cc=alx.manpages@gmail.com \
    --cc=gcc@gcc.gnu.org \
    --cc=libc-alpha@sourceware.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).