Support for memcpy with equal source and destination
Alexander Monakov
amonakov@ispras.ru
Mon Nov 27 11:46:33 GMT 2023
On Mon, 27 Nov 2023, Ralf Jung wrote:
> This probably needs benchmark to determine on which side the branch is less
> expensive overall? Or a dedicated memcpy variant that allows src==dest, as has
> been brought up elsewhere.
Please note that GCC does not use memcpy for "sufficiently small" structure
copies at -O2, as it's faster to emit the necessary loads+stores inline.
The threshold for "sufficiently small" varies with target and compiler version;
for instance, it is "above 64 bytes" for 32-bit arm and "above 8192 bytes" for
x86_64 with current trunk (it also depends on default -march/-mtune, etc.).
So on x86 at least adding such a branch in memcpy is not a practical choice.
Alexander
More information about the Libc-alpha
mailing list