786673
commit 1d21fb1061cbeb50414a8f371abb36548d90f150
786673
Author: Stefan Liebler <stli@linux.ibm.com>
786673
Date:   Fri Jun 26 09:45:11 2020 +0200
786673
786673
    S390: Optimize __memset_z196.
786673
    
786673
    It turned out that an 256b-mvc instruction which depends on the
786673
    result of a previous 256b-mvc instruction is counterproductive.
786673
    Therefore this patch adjusts the 256b-loop by storing the
786673
    first byte with stc and setting the remaining 255b with mvc.
786673
    Now the 255b-mvc instruction depends on the stc instruction.
786673
786673
diff --git a/sysdeps/s390/memset-z900.S b/sysdeps/s390/memset-z900.S
786673
index ca3eac0522..1e0c334156 100644
786673
--- a/sysdeps/s390/memset-z900.S
786673
+++ b/sysdeps/s390/memset-z900.S
786673
@@ -157,28 +157,27 @@ ENTRY(MEMSET_Z196)
786673
 # if !defined __s390x__
786673
 	llgfr	%r4,%r4
786673
 # endif /* !defined __s390x__  */
786673
-	ltgr    %r4,%r4
786673
-	je      .L_Z196_4
786673
+	clgfi	%r4,1
786673
+	jl	.L_Z196_4	    # n == 0
786673
 	stc     %r3,0(%r2)
786673
+	je      .L_Z196_4	    # n == 1
786673
+	aghi	%r4,-2
786673
 	lgr     %r1,%r2
786673
-	cghi    %r4,1
786673
-	je      .L_Z196_4
786673
-	aghi    %r4,-2
786673
-	srlg    %r5,%r4,8
786673
-	ltgr    %r5,%r5
786673
-	jne     .L_Z196_1
786673
+	risbg	%r5,%r4,8,128+63,56 # r5 = n / 256
786673
+	jne     .L_Z196_1	    # Jump away if r5 != 0
786673
 .L_Z196_3:
786673
 	exrl    %r4,.L_Z196_17
786673
 .L_Z196_4:
786673
 	br      %r14
786673
 .L_Z196_1:
786673
 	cgfi	%r5,1048576
786673
-	jh	__memset_mvcle	   # Switch to mvcle for >256MB
786673
+	jh	__memset_mvcle	    # Switch to mvcle for >256MB
786673
 .L_Z196_2:
786673
 	pfd     2,1024(%r1)
786673
-	mvc     1(256,%r1),0(%r1)
786673
+	mvc     1(255,%r1),0(%r1)
786673
 	aghi    %r5,-1
786673
 	la      %r1,256(%r1)
786673
+	stc     %r3,0(%r1)
786673
 	jne     .L_Z196_2
786673
 	j       .L_Z196_3
786673
 .L_Z196_17: