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.