This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: memcpy(a,b,CONST) is not inlined by gcc 3.4.1 in Linux kernel
- From: Andrew Pinski <pinskia at physics dot uc dot edu>
- To: jakub at redhat dot com
- Cc: vda at ilport dot com dot ua (Denis Vlasenko), linux-kernel at vger dot kernel dot org, gcc at gcc dot gnu dot org
- Date: Tue, 29 Mar 2005 10:42:04 -0500 (EST)
- Subject: Re: memcpy(a,b,CONST) is not inlined by gcc 3.4.1 in Linux kernel
>
> On Tue, Mar 29, 2005 at 05:37:06PM +0300, Denis Vlasenko wrote:
> > /*
> > * This looks horribly ugly, but the compiler can optimize it totally,
> > * as the count is constant.
> > */
> > static inline void * __constant_memcpy(void * to, const void * from, size_t n)
> > {
> > if (n <= 128)
> > return __builtin_memcpy(to, from, n);
> The problem is that in GCC < 4.0 there is no constant propagation
> pass before expanding builtin functions, so the __builtin_memcpy
> call above sees a variable rather than a constant.
or change "size_t n" to "const size_t n" will also fix the issue.
As we do some (well very little and with inlining and const values)
const progation before 4.0.0 on the trees before expanding the builtin.
-- Pinski