arch/x86/memcpy.c: Optimize code for 64bit
In 64bit movsq is available which moves memory in chunks of 8 bytes rather than 4 bytes. Linux uses the same code. Signed-off-by: Arthur Heymans <arthur@aheymans.xyz> Change-Id: I65f178d2ed3aae54b0c1ce739c2b4af8738b9fcc Reviewed-on: https://review.coreboot.org/c/coreboot/+/78646 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Felix Held <felix-coreboot@felixheld.de> Reviewed-by: Martin Roth <martin.roth@amd.corp-partner.google.com> Reviewed-by: Jérémy Compostella <jeremy.compostella@intel.com> Reviewed-by: Eric Lai <ericllai@google.com>
This commit is contained in:
parent
8bd7d6c806
commit
fdf85614dc
|
@ -14,19 +14,26 @@ void *memcpy(void *dest, const void *src, size_t n)
|
|||
check_memory_region((unsigned long)dest, n, true, _RET_IP_);
|
||||
#endif
|
||||
|
||||
asm volatile(
|
||||
#if ENV_X86_64
|
||||
"rep ; movsd\n\t"
|
||||
asm volatile(
|
||||
"rep ; movsq\n\t"
|
||||
"mov %4,%%rcx\n\t"
|
||||
"rep ; movsb\n\t"
|
||||
: "=&c" (d0), "=&D" (d1), "=&S" (d2)
|
||||
: "0" (n >> 3), "g" (n & 7), "1" (dest), "2" (src)
|
||||
: "memory"
|
||||
);
|
||||
#else
|
||||
asm volatile(
|
||||
"rep ; movsl\n\t"
|
||||
"movl %4,%%ecx\n\t"
|
||||
#endif
|
||||
"rep ; movsb\n\t"
|
||||
: "=&c" (d0), "=&D" (d1), "=&S" (d2)
|
||||
: "0" (n >> 2), "g" (n & 3), "1" (dest), "2" (src)
|
||||
: "memory"
|
||||
);
|
||||
#endif
|
||||
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue