This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: memcpy


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]