This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: memcpy
- From: Nathan Myers <ncm-nospam at cantrip dot org>
- To: libstdc++ at gcc dot gnu dot org
- Cc: rth at redhat dot com
- Date: Wed, 19 Feb 2003 18:32:02 -0800
- Subject: Re: memcpy
- References: <20030220004728.GA28446@redhat.com>
On Wed, Feb 19, 2003 at 04:47:28PM -0800, Richard Henderson wrote:
> [ re: http://gcc.gnu.org/ml/libstdc++/2003-02/msg00056.html ]
>
>
> ... our inliner is happy to do constant propagation, but *only* if the
> argument itself is marked constant. I.e.
>
> inline void foo(void * const x, const void * const y, size_t const s)
> { memcpy(x, y, s); }
>
> instead of
>
> inline void foo(void * x, const void * y, size_t s)
> { memcpy(x, y, s); }
Cool! But why would the optimizer *care* whether s is const, but
not x and y? Well, we can declare it
inline void foo(void * const x, const void * const y, size_t s)
if we have to. But it seems to me the compiler would be freer the
other way, allowed to clobber the registers that x, y, and s are
(were) in.
> I don't know if you're allowed to make this change at will
> though, since it probably affects name mangling?
Constness on value-parameters doesn't affect anything in the interface.
We're totally free to make this change.
Nathan Myers
ncm-nospam at cantrip dot org