lkml.org 
[lkml]   [1998]   [Jan]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: kernel and egcs
> > In this case I would just accommodate the compiler:
> >
> > /* include/asm-i386/string.h */
> > switch (n % 4) {
> > case 0: COMMON(""); break;
> > case 1: COMMON("\n\tmovsb"); break;
> > case 2: COMMON("\n\tmovsw"); break;
> > case 3: COMMON("\n\tmovsw\n\tmovsb"); break;
> > }
> > return to;
> It is slower : it adds one unuseful jump compared to the original code

Using what compiler? With either gcc 2.7.2, or egcs, the function

char *f()
{
char buf1[37],buf2[37];
return __constant_memcpy(buf1,buf2,sizeof(buf1));
}

gets compiled to

leal -40(%ebp),%edx
leal -80(%ebp),%eax
movl $9,%ecx
movl %edx,%edi
movl %eax,%esi
#APP
cld
rep ; movsl
movsb
#NO_APP
...
movl %edx,%eax

there are no jump instructions in the surrounding code. It just saves
the registers that are defined as being destroyed. So if this is
changed, I propose to use the code above: it is straight-forward to
read, does what people want, and looks fine to the compiler.

Regards,
Martin

P.S. There is still room for further optimizations: the register
allocation is sub-optimal, and with better hints, the compiler
could detect that f does essentially nothing.

\
 
 \ /
  Last update: 2005-03-22 13:41    [W:0.384 / U:0.228 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site