[PATCH v3 1/2] powerpc: Add optimized strncpy for POWER9

Tulio Magno Quites Machado Filho tuliom@ascii.art.br
Thu Nov 12 17:09:59 GMT 2020


Raphael Moreira Zinsly <rzinsly@linux.ibm.com> writes:

> Similar to the strcpy P9 optimization, this version uses VSX to improve
> performance.

Remember to add the Reviewed-by: lines you collected in previous versions. ;-)

> +#define FRAMESIZE (FRAME_MIN_SIZE+48)

I think you actually meant to use FRAME_MIN_SIZE+8 here.
Fixed.

> +L(zero_padding_end):
> +	sldi	r10,r5,56	/* stxvl wants size in top 8 bits  */
> +	stxvl	v18,r11,r10	/* Partial store  */
> +	blr
> +
> +	.align	4
> +L(zero_padding_memset):
> +	std	r30,-8(r1)   /* Save r30 on the stack.  */

This requires to add CFI:

	cfi_offset(r30, -8)

Done.

> +#if defined __LITTLE_ENDIAN__ && IS_IN (libc)
> +#define STRNCPY __strncpy_power9
> +
> +#undef libc_hidden_builtin_def
> +#define libc_hidden_builtin_def(name)
> +
> +/* memset is used to pad the end of the string.  */
> +#define MEMSET __memset_power8
> +#ifdef SHARED
> +#define MEMSET_is_local

Wrong indentation in the previous lines.  Fixed.

I wonder if we can improve this and stop depending on the list of memset
implementations on this file.
Anyway, this isn't new and is a future work.

> diff --git a/sysdeps/powerpc/powerpc64/multiarch/strncpy.c b/sysdeps/powerpc/powerpc64/multiarch/strncpy.c
> index 7bacf28aca..3f2108ddae 100644
> --- a/sysdeps/powerpc/powerpc64/multiarch/strncpy.c
> +++ b/sysdeps/powerpc/powerpc64/multiarch/strncpy.c
> @@ -28,11 +28,19 @@
>  extern __typeof (strncpy) __strncpy_ppc attribute_hidden;
>  extern __typeof (strncpy) __strncpy_power7 attribute_hidden;
>  extern __typeof (strncpy) __strncpy_power8 attribute_hidden;
> +# ifdef __LITTLE_ENDIAN__
> +extern __typeof (strncpy) __strncpy_power9 attribute_hidden;
> +# endif
>  # undef strncpy
>  
>  /* Avoid DWARF definition DIE on ifunc symbol so that GDB can handle
>   ifunc symbol properly. */
>  libc_ifunc_redirected (__redirect_strncpy, strncpy,
> +# ifdef __LITTLE_ENDIAN__
> +		     (hwcap2 & PPC_FEATURE2_ARCH_3_00) &&
> +		     (hwcap & PPC_FEATURE_HAS_VSX)
> +		     ? __strncpy_power9 :

Wrong indentation here.  Fixed.

Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>

Pushed as b9d83bf3eb57.

Thanks!

-- 
Tulio Magno


More information about the Libc-alpha mailing list