This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Gcc builtin review: strcpy, stpcpy, strcat, stpcat?
- From: Richard Earnshaw <Richard dot Earnshaw at foss dot arm dot com>
- To: OndÅej BÃlka <neleai at seznam dot cz>, libc-alpha at sourceware dot org
- Cc: Andrew Pinski <pinskia at gmail dot com>
- Date: Thu, 04 Jun 2015 11:27:57 +0100
- Subject: Re: Gcc builtin review: strcpy, stpcpy, strcat, stpcat?
- Authentication-results: sourceware.org; auth=none
- References: <20150525101505 dot GA11233 at domone> <20150525114545 dot GC11233 at domone>
On 25/05/15 12:45, OndÅej BÃlka wrote:
> Replaces it with strcpy. One could argue that opposite way to replace
> strcpy with stpcpy is faster.
>
> Reason is register pressure. Strcpy needs extra register to save return
> value while stpcpy has return value already in register used for writing
> terminating zero.
Depends on your architecture. On aarch64 we have plenty of spare
registers, so strcpy simply copies the destination register into a
scratch. It then doesn't have to carefully calculate the return value
at the end of the function (making the tail code simpler - there are
multiple return statements, but only one entry point).
R.