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