[PATCH] s390: Use 64bit branch relative on count instruction in strncpy-z900.S [BZ #34398]

Stefan Liebler stli@linux.ibm.com
Tue Jul 14 09:00:08 GMT 2026


On 7/14/26 10:56, Stefan Liebler wrote:
> At the time the s390-32 strncpy implementation was adjusted for the
> s390-64 port, the brct (branch relative on count) instruction was
> not adjusted from 32bit to 64bit instruction.
> 
> If n contains a value >32bit, the number of 8 byte chunks is computed
> with srlg (64bit shift right). The processing of 8 byte chunks is then
> processed by looping with brct (32bit branch relative on count) instruction.
> 
> This patch just uses the brctg (64bit branch relative on count) instruciton.
> 
> Note 1: There is a second loop copying the remaining seven bytes.  The usage
> of 32bit brct for looping is fine here.
> 
> Note 2: If glibc is build with architecture level set >=z13, the z900 variant
> of strncpy is not build at all.
> 
> Note 3: If glibc is build for <z13, the z900 ifunc variant is only chosen if
> not run on >=z13 or if called via __GI_strncpy.
> ---
>  sysdeps/s390/strncpy-z900.S | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/sysdeps/s390/strncpy-z900.S b/sysdeps/s390/strncpy-z900.S
> index 6d954cf402..141cba2294 100644
> --- a/sysdeps/s390/strncpy-z900.S
> +++ b/sysdeps/s390/strncpy-z900.S
> @@ -56,7 +56,7 @@ ENTRY(STRNCPY_Z900)
>  	jz    .L10
>  	stg   %r0,0(%r2,%r3)	    # store all eight to dest.
>  	la    %r3,8(%r3)
> -	brct  %r4,.L0
> +	brctg %r4,.L0
>  .L1:	ltgr  %r1,%r1
>  	jz    .Lexit
>  .L2:	icm   %r0,1,0(%r3)

Hi Andreas,

can I just push this to master before the release?

Bye,
Stefan


More information about the Libc-alpha mailing list