public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Should GCC provide __builtin_memcpy_inline like clang does?
@ 2021-01-19 11:33 unlvsur unlvsur
  2021-01-19 18:51 ` Segher Boessenkool
  2021-01-20  2:41 ` Gabriel Ravier
  0 siblings, 2 replies; 6+ messages in thread
From: unlvsur unlvsur @ 2021-01-19 11:33 UTC (permalink / raw)
  To: gcc, gcc-help

I think __builtin_memmove_inline, __builtin_memset_inline can also get provided.

That allows better performance for small size copies and allowing memcpy to be usable without libc.

Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986> for Windows 10


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Should GCC provide __builtin_memcpy_inline like clang does?
  2021-01-19 11:33 Should GCC provide __builtin_memcpy_inline like clang does? unlvsur unlvsur
@ 2021-01-19 18:51 ` Segher Boessenkool
  2021-01-19 20:02   ` unlvsur unlvsur
  2021-01-20  2:41 ` Gabriel Ravier
  1 sibling, 1 reply; 6+ messages in thread
From: Segher Boessenkool @ 2021-01-19 18:51 UTC (permalink / raw)
  To: unlvsur unlvsur; +Cc: gcc, gcc-help

On Tue, Jan 19, 2021 at 11:33:56AM +0000, unlvsur unlvsur via Gcc-help wrote:
> I think __builtin_memmove_inline, __builtin_memset_inline can also get provided.
> 
> That allows better performance for small size copies

You normally will get better performance by letting the compiler figure
out whether to inline or not.  That is what the Power port does, for
example.

> and allowing memcpy to be usable without libc.

You can provide your own non-standard-named function anyway?


In either case, feature requests should go into bugzilla, or they will
more than likely be lost.

Thanks,


Segher

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: Should GCC provide __builtin_memcpy_inline like clang does?
  2021-01-19 18:51 ` Segher Boessenkool
@ 2021-01-19 20:02   ` unlvsur unlvsur
  2021-01-20  7:27     ` Richard Biener
  0 siblings, 1 reply; 6+ messages in thread
From: unlvsur unlvsur @ 2021-01-19 20:02 UTC (permalink / raw)
  To: Segher Boessenkool, gcc

That is not for inline. That is to allow implementing memcpy without introducing any libc runtime which allows us to use it in freestanding environment.

Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986> for Windows 10

From: Segher Boessenkool<mailto:segher@kernel.crashing.org>
Sent: Tuesday, January 19, 2021 13:52
To: unlvsur unlvsur<mailto:unlvsur@live.com>
Cc: gcc@gcc.gnu.org<mailto:gcc@gcc.gnu.org>; gcc-help@gcc.gnu.org<mailto:gcc-help@gcc.gnu.org>
Subject: Re: Should GCC provide __builtin_memcpy_inline like clang does?

On Tue, Jan 19, 2021 at 11:33:56AM +0000, unlvsur unlvsur via Gcc-help wrote:
> I think __builtin_memmove_inline, __builtin_memset_inline can also get provided.
>
> That allows better performance for small size copies

You normally will get better performance by letting the compiler figure
out whether to inline or not.  That is what the Power port does, for
example.

> and allowing memcpy to be usable without libc.

You can provide your own non-standard-named function anyway?


In either case, feature requests should go into bugzilla, or they will
more than likely be lost.

Thanks,


Segher


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Should GCC provide __builtin_memcpy_inline like clang does?
  2021-01-19 11:33 Should GCC provide __builtin_memcpy_inline like clang does? unlvsur unlvsur
  2021-01-19 18:51 ` Segher Boessenkool
@ 2021-01-20  2:41 ` Gabriel Ravier
  2021-01-20  2:52   ` H.J. Lu
  1 sibling, 1 reply; 6+ messages in thread
From: Gabriel Ravier @ 2021-01-20  2:41 UTC (permalink / raw)
  To: gcc, gcc-help

On 1/19/21 12:33 PM, unlvsur unlvsur via Gcc wrote:
> I think __builtin_memmove_inline, __builtin_memset_inline can also get 
> provided.
>
> That allows better performance for small size copies

Manual tweaking like that seems a bit ridiculous except in very narrow 
situations, and just letting GCC assume there is an implementation of 
memset/memmove lets it do optimization based on copy size by default. I 
guess there could be some value to such an extension for portably doing 
such specific micro-optimizations manually, though.

> and allowing memcpy to be usable without libc.
You can just define it yourself, don't worry, GCC won't mind (as long as 
it has the correct semantics). Even for the narrow case of memmove, 
which could be mildly inconvenient to implement in less than 10 lines on 
a few systems that have non-trivial pointers (i.e. `source < 
destination` doesn't work as expected), you're on freestanding, so you 
should be able to make some kind of working implementation by using 
non-standard stuff for that specific purpose.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Should GCC provide __builtin_memcpy_inline like clang does?
  2021-01-20  2:41 ` Gabriel Ravier
@ 2021-01-20  2:52   ` H.J. Lu
  0 siblings, 0 replies; 6+ messages in thread
From: H.J. Lu @ 2021-01-20  2:52 UTC (permalink / raw)
  To: Gabriel Ravier; +Cc: gcc, gcc-help

On Tue, Jan 19, 2021 at 6:44 PM Gabriel Ravier via Gcc <gcc@gcc.gnu.org> wrote:
>
> On 1/19/21 12:33 PM, unlvsur unlvsur via Gcc wrote:
> > I think __builtin_memmove_inline, __builtin_memset_inline can also get
> > provided.
> >
> > That allows better performance for small size copies
>
> Manual tweaking like that seems a bit ridiculous except in very narrow
> situations, and just letting GCC assume there is an implementation of
> memset/memmove lets it do optimization based on copy size by default. I
> guess there could be some value to such an extension for portably doing
> such specific micro-optimizations manually, though.
>
> > and allowing memcpy to be usable without libc.
> You can just define it yourself, don't worry, GCC won't mind (as long as
> it has the correct semantics). Even for the narrow case of memmove,
> which could be mildly inconvenient to implement in less than 10 lines on
> a few systems that have non-trivial pointers (i.e. `source <
> destination` doesn't work as expected), you're on freestanding, so you
> should be able to make some kind of working implementation by using
> non-standard stuff for that specific purpose.
>

FWIW, on x86, GCC 11 can inline all calls to memset, memcpy and
memcmp with -minline-all-stringops.

-- 
H.J.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Should GCC provide __builtin_memcpy_inline like clang does?
  2021-01-19 20:02   ` unlvsur unlvsur
@ 2021-01-20  7:27     ` Richard Biener
  0 siblings, 0 replies; 6+ messages in thread
From: Richard Biener @ 2021-01-20  7:27 UTC (permalink / raw)
  To: unlvsur unlvsur; +Cc: Segher Boessenkool, gcc

On Tue, Jan 19, 2021 at 9:04 PM unlvsur unlvsur via Gcc <gcc@gcc.gnu.org> wrote:
>
> That is not for inline. That is to allow implementing memcpy without introducing any libc runtime which allows us to use it in freestanding environment.

Note that GCC requires memcpy, memmove, memset and memcmp to exist even in
a freestanding environment since it may generate calls to those
functions itself.
So the argument of a freestanding env does not hold.

Richard.

> Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986> for Windows 10
>
> From: Segher Boessenkool<mailto:segher@kernel.crashing.org>
> Sent: Tuesday, January 19, 2021 13:52
> To: unlvsur unlvsur<mailto:unlvsur@live.com>
> Cc: gcc@gcc.gnu.org<mailto:gcc@gcc.gnu.org>; gcc-help@gcc.gnu.org<mailto:gcc-help@gcc.gnu.org>
> Subject: Re: Should GCC provide __builtin_memcpy_inline like clang does?
>
> On Tue, Jan 19, 2021 at 11:33:56AM +0000, unlvsur unlvsur via Gcc-help wrote:
> > I think __builtin_memmove_inline, __builtin_memset_inline can also get provided.
> >
> > That allows better performance for small size copies
>
> You normally will get better performance by letting the compiler figure
> out whether to inline or not.  That is what the Power port does, for
> example.
>
> > and allowing memcpy to be usable without libc.
>
> You can provide your own non-standard-named function anyway?
>
>
> In either case, feature requests should go into bugzilla, or they will
> more than likely be lost.
>
> Thanks,
>
>
> Segher
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-01-20  7:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-19 11:33 Should GCC provide __builtin_memcpy_inline like clang does? unlvsur unlvsur
2021-01-19 18:51 ` Segher Boessenkool
2021-01-19 20:02   ` unlvsur unlvsur
2021-01-20  7:27     ` Richard Biener
2021-01-20  2:41 ` Gabriel Ravier
2021-01-20  2:52   ` H.J. Lu

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).