Re: [PATCH v3 2/2] x86/lib: Use REP MOVSB for large memcpy() on ERMS CPUs without FSRM
From: David Laight
Date: Sun Nov 15 2026 - 18:01:15 EST
On Sun, 15 Nov 2026 10:45:22 -0800
Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
> On Sun, 15 Nov 2026 at 04:42, David Laight <david.laight.linux@xxxxxxxxx> wrote:
> >
> > > But having extra registers free could help at the call-site,
> >
> > There isn't much you can put at the call site instead of a 5 byte call.
>
> You misunderstand.
>
> Avoiding call-clobbered registers means that the caller has more
> registers live and can do better code generation.
I missed that was what you were thinking of.
Clearly you definitely want as few registers clobbered as possible.
It is a compromise, but current 'standard C calling convention
is horrid here'.
> Making the calling convention clobber registers that aren't useful is
> *bad*. And if you do a loop - which you know is either large or
> unknown size - and take the I$ hit, adding a couple of push/pop
> instructions really doesn't hurt AT ALL.
When I get around to some memcpy() performance measurements I'll
include it.
> It has nothing to do with the 5-byte "'call' or 'rep movsb'" instruction.
>
> (And I realize that 'rep movsb' is only two bytes. You'd add a 3-byte
> nop or harmless prefixes to it depending on which decodes better)
I'm not sure why I mentioned a two byte nop, I've been writing x86 asm
since 1982 and really should get it right.
David
>
> Linus
>