Messages in this thread | | | Date | Wed, 28 Jan 1998 00:31:44 +0100 | From | Martin von Loewis <> | Subject | Re: 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.
| |