[PATCH v2] powerpc: optimize strcpy and stpcpy for POWER9/10

Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Wed Jun 26 22:33:08 GMT 2024



On 26/06/24 11:34, MAHESH BODAPATI wrote:
> This patch modifies the current POWER9 implementation of strcpy and
> stpcpy to optimize it for POWER9/10.
> 
> Since no new POWER10 instructions are used, the original POWER9
> strcpy is modified instead of creating a new implementation for POWER10.
> 
> The changes also affect stpcpy, which uses the same implementation
> with some additional code before returning.
> 
> Improvements compared to POWER9 version:
> 
> Use simple comparisons for the first ~512 bytes
>   The main loop is good for long strings, but comparing 16B each time is
>   better for shorter strings. After aligning the address to 16 bytes, we
>   unroll the loop four times, checking 128 bytes each time. There may be
>   some overlap with the main loop for unaligned strings, but it is better
>   for shorter strings.
> 
> Loop with 64 bytes for longer bytes
>   using 4 consecutive lxv/stxv instructions.
> 
> Showed an average improvement of 13% and the degradations for smaller
> strings are not consistent.

Other implementations either focus on small sizes or add fast-paths code
assuming small sizes are more common than larger one.  You might reevaluate
if this implementation if really worth if you are seeing smaller size
regressions. 


More information about the Libc-alpha mailing list