Blame SOURCES/glibc-ppc64le-27.patch

147e83
# commit 8a7413f9b036da83ffde491a37d9d2340bc321a7
147e83
# Author: Alan Modra <amodra@gmail.com>
147e83
# Date:   Sat Aug 17 18:41:17 2013 +0930
147e83
# 
147e83
#     PowerPC LE strcmp and strncmp
147e83
#     http://sourceware.org/ml/libc-alpha/2013-08/msg00099.html
147e83
#     
147e83
#     More little-endian support.  I leave the main strcmp loops unchanged,
147e83
#     (well, except for renumbering rTMP to something other than r0 since
147e83
#     it's needed in an addi insn) and modify the tail for little-endian.
147e83
#     
147e83
#     I noticed some of the big-endian tail code was a little untidy so have
147e83
#     cleaned that up too.
147e83
#     
147e83
#         * sysdeps/powerpc/powerpc64/strcmp.S (rTMP2): Define as r0.
147e83
#         (rTMP): Define as r11.
147e83
#         (strcmp): Add little-endian support.  Optimise tail.
147e83
#         * sysdeps/powerpc/powerpc32/strcmp.S: Similarly.
147e83
#         * sysdeps/powerpc/powerpc64/strncmp.S: Likewise.
147e83
#         * sysdeps/powerpc/powerpc32/strncmp.S: Likewise.
147e83
#         * sysdeps/powerpc/powerpc64/power4/strncmp.S: Likewise.
147e83
#         * sysdeps/powerpc/powerpc32/power4/strncmp.S: Likewise.
147e83
#         * sysdeps/powerpc/powerpc64/power7/strncmp.S: Likewise.
147e83
#         * sysdeps/powerpc/powerpc32/power7/strncmp.S: Likewise.
147e83
# 
147e83
diff -urN glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/power4/strncmp.S glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/power4/strncmp.S
147e83
--- glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/power4/strncmp.S	2014-05-28 13:26:59.000000000 -0500
147e83
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/power4/strncmp.S	2014-05-28 13:27:02.000000000 -0500
147e83
@@ -26,7 +26,7 @@
147e83
 
147e83
 EALIGN (BP_SYM(strncmp), 4, 0)
147e83
 
147e83
-#define rTMP	r0
147e83
+#define rTMP2	r0
147e83
 #define rRTN	r3
147e83
 #define rSTR1	r3	/* first string arg */
147e83
 #define rSTR2	r4	/* second string arg */
147e83
@@ -42,6 +42,7 @@
147e83
 #define r7F7F	r9	/* constant 0x7f7f7f7f */
147e83
 #define rNEG	r10	/* ~(word in s1 | 0x7f7f7f7f) */
147e83
 #define rBITDIF	r11	/* bits that differ in s1 & s2 words */
147e83
+#define rTMP	r12
147e83
 
147e83
 	dcbt	0,rSTR1
147e83
 	or	rTMP, rSTR2, rSTR1
147e83
@@ -80,12 +81,45 @@
147e83
    we don't compare two strings as different because of gunk beyond
147e83
    the end of the strings...  */
147e83
 
147e83
+#ifdef __LITTLE_ENDIAN__
147e83
+L(endstring):
147e83
+	slwi	rTMP, rTMP, 1
147e83
+	addi    rTMP2, rTMP, -1
147e83
+	andc    rTMP2, rTMP2, rTMP
147e83
+	and	rWORD2, rWORD2, rTMP2		/* Mask off gunk.  */
147e83
+	and	rWORD1, rWORD1, rTMP2
147e83
+	rlwinm	rTMP2, rWORD2, 8, 0xffffffff	/* Byte reverse word.  */
147e83
+	rlwinm	rTMP, rWORD1, 8, 0xffffffff
147e83
+	rldimi	rTMP2, rWORD2, 24, 32
147e83
+	rldimi	rTMP, rWORD1, 24, 32
147e83
+	rlwimi	rTMP2, rWORD2, 24, 16, 23
147e83
+	rlwimi	rTMP, rWORD1, 24, 16, 23
147e83
+	xor.	rBITDIF, rTMP, rTMP2
147e83
+	sub	rRTN, rTMP, rTMP2
147e83
+	bgelr+
147e83
+	ori	rRTN, rTMP2, 1
147e83
+	blr
147e83
+
147e83
+L(different):
147e83
+	lwz	rWORD1, -4(rSTR1)
147e83
+	rlwinm	rTMP2, rWORD2, 8, 0xffffffff	/* Byte reverse word.  */
147e83
+	rlwinm	rTMP, rWORD1, 8, 0xffffffff
147e83
+	rldimi	rTMP2, rWORD2, 24, 32
147e83
+	rldimi	rTMP, rWORD1, 24, 32
147e83
+	rlwimi	rTMP2, rWORD2, 24, 16, 23
147e83
+	rlwimi	rTMP, rWORD1, 24, 16, 23
147e83
+	xor.	rBITDIF, rTMP, rTMP2
147e83
+	sub	rRTN, rTMP, rTMP2
147e83
+	bgelr+
147e83
+	ori	rRTN, rTMP2, 1
147e83
+	blr
147e83
+
147e83
+#else
147e83
 L(endstring):
147e83
 	and	rTMP, r7F7F, rWORD1
147e83
 	beq	cr1, L(equal)
147e83
 	add	rTMP, rTMP, r7F7F
147e83
 	xor.	rBITDIF, rWORD1, rWORD2
147e83
-
147e83
 	andc	rNEG, rNEG, rTMP
147e83
 	blt-	L(highbit)
147e83
 	cntlzw	rBITDIF, rBITDIF
147e83
@@ -93,28 +127,20 @@
147e83
 	addi	rNEG, rNEG, 7
147e83
 	cmpw	cr1, rNEG, rBITDIF
147e83
 	sub	rRTN, rWORD1, rWORD2
147e83
-	blt-	cr1, L(equal)
147e83
-	srawi	rRTN, rRTN, 31
147e83
-	ori	rRTN, rRTN, 1
147e83
-	blr
147e83
+	bgelr+	cr1
147e83
 L(equal):
147e83
 	li	rRTN, 0
147e83
 	blr
147e83
 
147e83
 L(different):
147e83
-	lwzu	rWORD1, -4(rSTR1)
147e83
+	lwz	rWORD1, -4(rSTR1)
147e83
 	xor.	rBITDIF, rWORD1, rWORD2
147e83
 	sub	rRTN, rWORD1, rWORD2
147e83
-	blt-	L(highbit)
147e83
-	srawi	rRTN, rRTN, 31
147e83
-	ori	rRTN, rRTN, 1
147e83
-	blr
147e83
+	bgelr+
147e83
 L(highbit):
147e83
-	srwi	rWORD2, rWORD2, 24
147e83
-	srwi	rWORD1, rWORD1, 24
147e83
-	sub	rRTN, rWORD1, rWORD2
147e83
+	ori	rRTN, rWORD2, 1
147e83
 	blr
147e83
-
147e83
+#endif
147e83
 
147e83
 /* Oh well.  In this case, we just do a byte-by-byte comparison.  */
147e83
 	.align 4
147e83
diff -urN glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/power7/strncmp.S glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/power7/strncmp.S
147e83
--- glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/power7/strncmp.S	2014-05-28 13:26:59.000000000 -0500
147e83
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/power7/strncmp.S	2014-05-28 13:27:02.000000000 -0500
147e83
@@ -28,7 +28,7 @@
147e83
 
147e83
 EALIGN (BP_SYM(strncmp),5,0)
147e83
 
147e83
-#define rTMP	r0
147e83
+#define rTMP2	r0
147e83
 #define rRTN	r3
147e83
 #define rSTR1	r3	/* first string arg */
147e83
 #define rSTR2	r4	/* second string arg */
147e83
@@ -44,6 +44,7 @@
147e83
 #define r7F7F	r9	/* constant 0x7f7f7f7f */
147e83
 #define rNEG	r10	/* ~(word in s1 | 0x7f7f7f7f) */
147e83
 #define rBITDIF	r11	/* bits that differ in s1 & s2 words */
147e83
+#define rTMP	r12
147e83
 
147e83
 	dcbt	0,rSTR1
147e83
 	nop
147e83
@@ -83,13 +84,45 @@
147e83
 /* OK. We've hit the end of the string. We need to be careful that
147e83
    we don't compare two strings as different because of gunk beyond
147e83
    the end of the strings...  */
147e83
+#ifdef __LITTLE_ENDIAN__
147e83
+L(endstring):
147e83
+	slwi	rTMP, rTMP, 1
147e83
+	addi    rTMP2, rTMP, -1
147e83
+	andc    rTMP2, rTMP2, rTMP
147e83
+	and	rWORD2, rWORD2, rTMP2		/* Mask off gunk.  */
147e83
+	and	rWORD1, rWORD1, rTMP2
147e83
+	rlwinm	rTMP2, rWORD2, 8, 0xffffffff	/* Byte reverse word.  */
147e83
+	rlwinm	rTMP, rWORD1, 8, 0xffffffff
147e83
+	rldimi	rTMP2, rWORD2, 24, 32
147e83
+	rldimi	rTMP, rWORD1, 24, 32
147e83
+	rlwimi	rTMP2, rWORD2, 24, 16, 23
147e83
+	rlwimi	rTMP, rWORD1, 24, 16, 23
147e83
+	xor.	rBITDIF, rTMP, rTMP2
147e83
+	sub	rRTN, rTMP, rTMP2
147e83
+	bgelr
147e83
+	ori	rRTN, rTMP2, 1
147e83
+	blr
147e83
+
147e83
+L(different):
147e83
+	lwz	rWORD1, -4(rSTR1)
147e83
+	rlwinm	rTMP2, rWORD2, 8, 0xffffffff	/* Byte reverse word.  */
147e83
+	rlwinm	rTMP, rWORD1, 8, 0xffffffff
147e83
+	rldimi	rTMP2, rWORD2, 24, 32
147e83
+	rldimi	rTMP, rWORD1, 24, 32
147e83
+	rlwimi	rTMP2, rWORD2, 24, 16, 23
147e83
+	rlwimi	rTMP, rWORD1, 24, 16, 23
147e83
+	xor.	rBITDIF, rTMP, rTMP2
147e83
+	sub	rRTN, rTMP, rTMP2
147e83
+	bgelr
147e83
+	ori	rRTN, rTMP2, 1
147e83
+	blr
147e83
 
147e83
+#else
147e83
 L(endstring):
147e83
 	and	rTMP,r7F7F,rWORD1
147e83
 	beq	cr1,L(equal)
147e83
 	add	rTMP,rTMP,r7F7F
147e83
 	xor.	rBITDIF,rWORD1,rWORD2
147e83
-
147e83
 	andc	rNEG,rNEG,rTMP
147e83
 	blt	L(highbit)
147e83
 	cntlzw	rBITDIF,rBITDIF
147e83
@@ -97,28 +130,20 @@
147e83
 	addi	rNEG,rNEG,7
147e83
 	cmpw	cr1,rNEG,rBITDIF
147e83
 	sub	rRTN,rWORD1,rWORD2
147e83
-	blt	cr1,L(equal)
147e83
-	srawi	rRTN,rRTN,31
147e83
-	ori	rRTN,rRTN,1
147e83
-	blr
147e83
+	bgelr	cr1
147e83
 L(equal):
147e83
 	li	rRTN,0
147e83
 	blr
147e83
 
147e83
 L(different):
147e83
-	lwzu	rWORD1,-4(rSTR1)
147e83
+	lwz	rWORD1,-4(rSTR1)
147e83
 	xor.	rBITDIF,rWORD1,rWORD2
147e83
 	sub	rRTN,rWORD1,rWORD2
147e83
-	blt	L(highbit)
147e83
-	srawi	rRTN,rRTN,31
147e83
-	ori	rRTN,rRTN,1
147e83
-	blr
147e83
+	bgelr
147e83
 L(highbit):
147e83
-	srwi	rWORD2,rWORD2,24
147e83
-	srwi	rWORD1,rWORD1,24
147e83
-	sub	rRTN,rWORD1,rWORD2
147e83
+	ori	rRTN, rWORD2, 1
147e83
 	blr
147e83
-
147e83
+#endif
147e83
 
147e83
 /* Oh well. In this case, we just do a byte-by-byte comparison.  */
147e83
 	.align	4
147e83
diff -urN glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/strcmp.S glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/strcmp.S
147e83
--- glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/strcmp.S	2014-05-28 13:26:59.000000000 -0500
147e83
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/strcmp.S	2014-05-28 13:27:02.000000000 -0500
147e83
@@ -26,7 +26,7 @@
147e83
 
147e83
 EALIGN (BP_SYM (strcmp), 4, 0)
147e83
 
147e83
-#define rTMP	r0
147e83
+#define rTMP2	r0
147e83
 #define rRTN	r3
147e83
 #define rSTR1	r3	/* first string arg */
147e83
 #define rSTR2	r4	/* second string arg */
147e83
@@ -40,6 +40,7 @@
147e83
 #define r7F7F	r8	/* constant 0x7f7f7f7f */
147e83
 #define rNEG	r9	/* ~(word in s1 | 0x7f7f7f7f) */
147e83
 #define rBITDIF	r10	/* bits that differ in s1 & s2 words */
147e83
+#define rTMP	r11
147e83
 
147e83
 	CHECK_BOUNDS_LOW (rSTR1, rTMP, rHIGH1)
147e83
 	CHECK_BOUNDS_LOW (rSTR2, rTMP, rHIGH2)
147e83
@@ -64,10 +65,45 @@
147e83
 	and.	rTMP, rTMP, rNEG
147e83
 	cmpw	cr1, rWORD1, rWORD2
147e83
 	beq+	L(g0)
147e83
-L(endstring):
147e83
+
147e83
 /* OK. We've hit the end of the string. We need to be careful that
147e83
    we don't compare two strings as different because of gunk beyond
147e83
    the end of the strings...  */
147e83
+#ifdef __LITTLE_ENDIAN__
147e83
+L(endstring):
147e83
+	addi    rTMP2, rTMP, -1
147e83
+	andc    rTMP2, rTMP2, rTMP
147e83
+	rlwimi	rTMP2, rTMP2, 1, 0, 30
147e83
+	and	rWORD2, rWORD2, rTMP2		/* Mask off gunk.  */
147e83
+	and	rWORD1, rWORD1, rTMP2
147e83
+	rlwinm	rTMP2, rWORD2, 8, 0xffffffff	/* Byte reverse word.  */
147e83
+	rlwinm	rTMP, rWORD1, 8, 0xffffffff
147e83
+	rlwimi	rTMP2, rWORD2, 24, 0, 7
147e83
+	rlwimi	rTMP, rWORD1, 24, 0, 7
147e83
+	rlwimi	rTMP2, rWORD2, 24, 16, 23
147e83
+	rlwimi	rTMP, rWORD1, 24, 16, 23
147e83
+	xor.	rBITDIF, rTMP, rTMP2
147e83
+	sub	rRTN, rTMP, rTMP2
147e83
+	bgelr+
147e83
+	ori	rRTN, rTMP2, 1
147e83
+	blr
147e83
+
147e83
+L(different):
147e83
+	lwz	rWORD1, -4(rSTR1)
147e83
+	rlwinm	rTMP2, rWORD2, 8, 0xffffffff	/* Byte reverse word.  */
147e83
+	rlwinm	rTMP, rWORD1, 8, 0xffffffff
147e83
+	rlwimi	rTMP2, rWORD2, 24, 0, 7
147e83
+	rlwimi	rTMP, rWORD1, 24, 0, 7
147e83
+	rlwimi	rTMP2, rWORD2, 24, 16, 23
147e83
+	rlwimi	rTMP, rWORD1, 24, 16, 23
147e83
+	xor.	rBITDIF, rTMP, rTMP2
147e83
+	sub	rRTN, rTMP, rTMP2
147e83
+	bgelr+
147e83
+	ori	rRTN, rTMP2, 1
147e83
+	blr
147e83
+
147e83
+#else
147e83
+L(endstring):
147e83
 	and	rTMP, r7F7F, rWORD1
147e83
 	beq	cr1, L(equal)
147e83
 	add	rTMP, rTMP, r7F7F
147e83
@@ -94,7 +130,7 @@
147e83
 	ori	rRTN, rWORD2, 1
147e83
 	/* GKM FIXME: check high bounds.  */
147e83
 	blr
147e83
-
147e83
+#endif
147e83
 
147e83
 /* Oh well.  In this case, we just do a byte-by-byte comparison.  */
147e83
 	.align 4
147e83
diff -urN glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/strncmp.S glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/strncmp.S
147e83
--- glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/strncmp.S	2014-05-28 13:26:59.000000000 -0500
147e83
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/strncmp.S	2014-05-28 13:27:02.000000000 -0500
147e83
@@ -26,7 +26,7 @@
147e83
 
147e83
 EALIGN (BP_SYM(strncmp), 4, 0)
147e83
 
147e83
-#define rTMP	r0
147e83
+#define rTMP2	r0
147e83
 #define rRTN	r3
147e83
 #define rSTR1	r3	/* first string arg */
147e83
 #define rSTR2	r4	/* second string arg */
147e83
@@ -40,6 +40,7 @@
147e83
 #define r7F7F	r9	/* constant 0x7f7f7f7f */
147e83
 #define rNEG	r10	/* ~(word in s1 | 0x7f7f7f7f) */
147e83
 #define rBITDIF	r11	/* bits that differ in s1 & s2 words */
147e83
+#define rTMP	r12
147e83
 
147e83
 	dcbt	0,rSTR1
147e83
 	or	rTMP, rSTR2, rSTR1
147e83
@@ -78,12 +79,45 @@
147e83
    we don't compare two strings as different because of gunk beyond
147e83
    the end of the strings...  */
147e83
 
147e83
+#ifdef __LITTLE_ENDIAN__
147e83
+L(endstring):
147e83
+	slwi	rTMP, rTMP, 1
147e83
+	addi    rTMP2, rTMP, -1
147e83
+	andc    rTMP2, rTMP2, rTMP
147e83
+	and	rWORD2, rWORD2, rTMP2		/* Mask off gunk.  */
147e83
+	and	rWORD1, rWORD1, rTMP2
147e83
+	rlwinm	rTMP2, rWORD2, 8, 0xffffffff	/* Byte reverse word.  */
147e83
+	rlwinm	rTMP, rWORD1, 8, 0xffffffff
147e83
+	rlwimi	rTMP2, rWORD2, 24, 0, 7
147e83
+	rlwimi	rTMP, rWORD1, 24, 0, 7
147e83
+	rlwimi	rTMP2, rWORD2, 24, 16, 23
147e83
+	rlwimi	rTMP, rWORD1, 24, 16, 23
147e83
+	xor.	rBITDIF, rTMP, rTMP2
147e83
+	sub	rRTN, rTMP, rTMP2
147e83
+	bgelr+
147e83
+	ori	rRTN, rTMP2, 1
147e83
+	blr
147e83
+
147e83
+L(different):
147e83
+	lwz	rWORD1, -4(rSTR1)
147e83
+	rlwinm	rTMP2, rWORD2, 8, 0xffffffff	/* Byte reverse word.  */
147e83
+	rlwinm	rTMP, rWORD1, 8, 0xffffffff
147e83
+	rlwimi	rTMP2, rWORD2, 24, 0, 7
147e83
+	rlwimi	rTMP, rWORD1, 24, 0, 7
147e83
+	rlwimi	rTMP2, rWORD2, 24, 16, 23
147e83
+	rlwimi	rTMP, rWORD1, 24, 16, 23
147e83
+	xor.	rBITDIF, rTMP, rTMP2
147e83
+	sub	rRTN, rTMP, rTMP2
147e83
+	bgelr+
147e83
+	ori	rRTN, rTMP2, 1
147e83
+	blr
147e83
+
147e83
+#else
147e83
 L(endstring):
147e83
 	and	rTMP, r7F7F, rWORD1
147e83
 	beq	cr1, L(equal)
147e83
 	add	rTMP, rTMP, r7F7F
147e83
 	xor.	rBITDIF, rWORD1, rWORD2
147e83
-
147e83
 	andc	rNEG, rNEG, rTMP
147e83
 	blt-	L(highbit)
147e83
 	cntlzw	rBITDIF, rBITDIF
147e83
@@ -91,28 +125,20 @@
147e83
 	addi	rNEG, rNEG, 7
147e83
 	cmpw	cr1, rNEG, rBITDIF
147e83
 	sub	rRTN, rWORD1, rWORD2
147e83
-	blt-	cr1, L(equal)
147e83
-	srawi	rRTN, rRTN, 31
147e83
-	ori	rRTN, rRTN, 1
147e83
-	blr
147e83
+	bgelr+	cr1
147e83
 L(equal):
147e83
 	li	rRTN, 0
147e83
 	blr
147e83
 
147e83
 L(different):
147e83
-	lwzu	rWORD1, -4(rSTR1)
147e83
+	lwz	rWORD1, -4(rSTR1)
147e83
 	xor.	rBITDIF, rWORD1, rWORD2
147e83
 	sub	rRTN, rWORD1, rWORD2
147e83
-	blt-	L(highbit)
147e83
-	srawi	rRTN, rRTN, 31
147e83
-	ori	rRTN, rRTN, 1
147e83
-	blr
147e83
+	bgelr+
147e83
 L(highbit):
147e83
-	srwi	rWORD2, rWORD2, 24
147e83
-	srwi	rWORD1, rWORD1, 24
147e83
-	sub	rRTN, rWORD1, rWORD2
147e83
+	ori	rRTN, rWORD2, 1
147e83
 	blr
147e83
-
147e83
+#endif
147e83
 
147e83
 /* Oh well.  In this case, we just do a byte-by-byte comparison.  */
147e83
 	.align 4
147e83
diff -urN glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/power4/strncmp.S glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/power4/strncmp.S
147e83
--- glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/power4/strncmp.S	2014-05-28 13:26:59.000000000 -0500
147e83
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/power4/strncmp.S	2014-05-28 13:27:02.000000000 -0500
147e83
@@ -27,7 +27,7 @@
147e83
 EALIGN (BP_SYM(strncmp), 4, 0)
147e83
 	CALL_MCOUNT 3
147e83
 
147e83
-#define rTMP	r0
147e83
+#define rTMP2	r0
147e83
 #define rRTN	r3
147e83
 #define rSTR1	r3	/* first string arg */
147e83
 #define rSTR2	r4	/* second string arg */
147e83
@@ -43,6 +43,7 @@
147e83
 #define r7F7F	r9	/* constant 0x7f7f7f7f7f7f7f7f */
147e83
 #define rNEG	r10	/* ~(word in s1 | 0x7f7f7f7f7f7f7f7f) */
147e83
 #define rBITDIF	r11	/* bits that differ in s1 & s2 words */
147e83
+#define rTMP	r12
147e83
 
147e83
 	dcbt	0,rSTR1
147e83
 	or	rTMP, rSTR2, rSTR1
147e83
@@ -84,12 +85,59 @@
147e83
    we don't compare two strings as different because of gunk beyond
147e83
    the end of the strings...  */
147e83
 
147e83
+#ifdef __LITTLE_ENDIAN__
147e83
+L(endstring):
147e83
+	addi    rTMP2, rTMP, -1
147e83
+	beq	cr1, L(equal)
147e83
+	andc    rTMP2, rTMP2, rTMP
147e83
+	rldimi	rTMP2, rTMP2, 1, 0
147e83
+	and	rWORD2, rWORD2, rTMP2	/* Mask off gunk.  */
147e83
+	and	rWORD1, rWORD1, rTMP2
147e83
+	cmpd	cr1, rWORD1, rWORD2
147e83
+	beq	cr1, L(equal)
147e83
+	xor	rBITDIF, rWORD1, rWORD2	/* rBITDIF has bits that differ.  */
147e83
+	neg	rNEG, rBITDIF
147e83
+	and	rNEG, rNEG, rBITDIF	/* rNEG has LS bit that differs.  */
147e83
+	cntlzd	rNEG, rNEG		/* bitcount of the bit.  */
147e83
+	andi.	rNEG, rNEG, 56		/* bitcount to LS byte that differs. */
147e83
+	sld	rWORD1, rWORD1, rNEG	/* shift left to clear MS bytes.  */
147e83
+	sld	rWORD2, rWORD2, rNEG
147e83
+	xor.	rBITDIF, rWORD1, rWORD2
147e83
+	sub	rRTN, rWORD1, rWORD2
147e83
+	blt-	L(highbit)
147e83
+	sradi	rRTN, rRTN, 63		/* must return an int.  */
147e83
+	ori	rRTN, rRTN, 1
147e83
+	blr
147e83
+L(equal):
147e83
+	li	rRTN, 0
147e83
+	blr
147e83
+
147e83
+L(different):
147e83
+	ld	rWORD1, -8(rSTR1)
147e83
+	xor	rBITDIF, rWORD1, rWORD2	/* rBITDIF has bits that differ.  */
147e83
+	neg	rNEG, rBITDIF
147e83
+	and	rNEG, rNEG, rBITDIF	/* rNEG has LS bit that differs.  */
147e83
+	cntlzd	rNEG, rNEG		/* bitcount of the bit.  */
147e83
+	andi.	rNEG, rNEG, 56		/* bitcount to LS byte that differs. */
147e83
+	sld	rWORD1, rWORD1, rNEG	/* shift left to clear MS bytes.  */
147e83
+	sld	rWORD2, rWORD2, rNEG
147e83
+	xor.	rBITDIF, rWORD1, rWORD2
147e83
+	sub	rRTN, rWORD1, rWORD2
147e83
+	blt-	L(highbit)
147e83
+	sradi	rRTN, rRTN, 63
147e83
+	ori	rRTN, rRTN, 1
147e83
+	blr
147e83
+L(highbit):
147e83
+	sradi	rRTN, rWORD2, 63
147e83
+	ori	rRTN, rRTN, 1
147e83
+	blr
147e83
+
147e83
+#else
147e83
 L(endstring):
147e83
 	and	rTMP, r7F7F, rWORD1
147e83
 	beq	cr1, L(equal)
147e83
 	add	rTMP, rTMP, r7F7F
147e83
 	xor.	rBITDIF, rWORD1, rWORD2
147e83
-
147e83
 	andc	rNEG, rNEG, rTMP
147e83
 	blt-	L(highbit)
147e83
 	cntlzd	rBITDIF, rBITDIF
147e83
@@ -98,7 +146,7 @@
147e83
 	cmpd	cr1, rNEG, rBITDIF
147e83
 	sub	rRTN, rWORD1, rWORD2
147e83
 	blt-	cr1, L(equal)
147e83
-	sradi	rRTN, rRTN, 63
147e83
+	sradi	rRTN, rRTN, 63		/* must return an int.  */
147e83
 	ori	rRTN, rRTN, 1
147e83
 	blr
147e83
 L(equal):
147e83
@@ -106,7 +154,7 @@
147e83
 	blr
147e83
 
147e83
 L(different):
147e83
-	ldu	rWORD1, -8(rSTR1)
147e83
+	ld	rWORD1, -8(rSTR1)
147e83
 	xor.	rBITDIF, rWORD1, rWORD2
147e83
 	sub	rRTN, rWORD1, rWORD2
147e83
 	blt-	L(highbit)
147e83
@@ -114,11 +162,10 @@
147e83
 	ori	rRTN, rRTN, 1
147e83
 	blr
147e83
 L(highbit):
147e83
-	srdi	rWORD2, rWORD2, 56
147e83
-	srdi	rWORD1, rWORD1, 56
147e83
-	sub	rRTN, rWORD1, rWORD2
147e83
+	sradi	rRTN, rWORD2, 63
147e83
+	ori	rRTN, rRTN, 1
147e83
 	blr
147e83
-
147e83
+#endif
147e83
 
147e83
 /* Oh well.  In this case, we just do a byte-by-byte comparison.  */
147e83
 	.align 4
147e83
diff -urN glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/power7/strncmp.S glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/power7/strncmp.S
147e83
--- glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/power7/strncmp.S	2014-05-28 13:26:59.000000000 -0500
147e83
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/power7/strncmp.S	2014-05-28 13:27:02.000000000 -0500
147e83
@@ -29,7 +29,7 @@
147e83
 EALIGN (BP_SYM(strncmp),5,0)
147e83
 	CALL_MCOUNT 3
147e83
 
147e83
-#define rTMP	r0
147e83
+#define rTMP2	r0
147e83
 #define rRTN	r3
147e83
 #define rSTR1	r3	/* first string arg */
147e83
 #define rSTR2	r4	/* second string arg */
147e83
@@ -45,6 +45,7 @@
147e83
 #define r7F7F	r9	/* constant 0x7f7f7f7f7f7f7f7f */
147e83
 #define rNEG	r10	/* ~(word in s1 | 0x7f7f7f7f7f7f7f7f) */
147e83
 #define rBITDIF	r11	/* bits that differ in s1 & s2 words */
147e83
+#define rTMP	r12
147e83
 
147e83
 	dcbt	0,rSTR1
147e83
 	nop
147e83
@@ -88,12 +89,57 @@
147e83
    we don't compare two strings as different because of gunk beyond
147e83
    the end of the strings...  */
147e83
 
147e83
+#ifdef __LITTLE_ENDIAN__
147e83
+L(endstring):
147e83
+	addi    rTMP2, rTMP, -1
147e83
+	beq	cr1, L(equal)
147e83
+	andc    rTMP2, rTMP2, rTMP
147e83
+	rldimi	rTMP2, rTMP2, 1, 0
147e83
+	and	rWORD2, rWORD2, rTMP2	/* Mask off gunk.  */
147e83
+	and	rWORD1, rWORD1, rTMP2
147e83
+	cmpd	cr1, rWORD1, rWORD2
147e83
+	beq	cr1, L(equal)
147e83
+	cmpb	rBITDIF, rWORD1, rWORD2	/* 0xff on equal bytes.  */
147e83
+	addi	rNEG, rBITDIF, 1
147e83
+	orc	rNEG, rNEG, rBITDIF	/* 0's below LS differing byte.  */
147e83
+	sldi	rNEG, rNEG, 8		/* 1's above LS differing byte.  */
147e83
+	andc	rWORD1, rWORD1, rNEG	/* mask off MS bytes.  */
147e83
+	andc	rWORD2, rWORD2, rNEG
147e83
+	xor.	rBITDIF, rWORD1, rWORD2
147e83
+	sub	rRTN, rWORD1, rWORD2
147e83
+	blt	L(highbit)
147e83
+	sradi	rRTN, rRTN, 63		/* must return an int.  */
147e83
+	ori	rRTN, rRTN, 1
147e83
+	blr
147e83
+L(equal):
147e83
+	li	rRTN, 0
147e83
+	blr
147e83
+
147e83
+L(different):
147e83
+	ld	rWORD1, -8(rSTR1)
147e83
+	cmpb	rBITDIF, rWORD1, rWORD2	/* 0xff on equal bytes.  */
147e83
+	addi	rNEG, rBITDIF, 1
147e83
+	orc	rNEG, rNEG, rBITDIF	/* 0's below LS differing byte.  */
147e83
+	sldi	rNEG, rNEG, 8		/* 1's above LS differing byte.  */
147e83
+	andc	rWORD1, rWORD1, rNEG	/* mask off MS bytes.  */
147e83
+	andc	rWORD2, rWORD2, rNEG
147e83
+	xor.	rBITDIF, rWORD1, rWORD2
147e83
+	sub	rRTN, rWORD1, rWORD2
147e83
+	blt	L(highbit)
147e83
+	sradi	rRTN, rRTN, 63
147e83
+	ori	rRTN, rRTN, 1
147e83
+	blr
147e83
+L(highbit):
147e83
+	sradi	rRTN, rWORD2, 63
147e83
+	ori	rRTN, rRTN, 1
147e83
+	blr
147e83
+
147e83
+#else
147e83
 L(endstring):
147e83
 	and	rTMP,r7F7F,rWORD1
147e83
 	beq	cr1,L(equal)
147e83
 	add	rTMP,rTMP,r7F7F
147e83
 	xor.	rBITDIF,rWORD1,rWORD2
147e83
-
147e83
 	andc	rNEG,rNEG,rTMP
147e83
 	blt	L(highbit)
147e83
 	cntlzd	rBITDIF,rBITDIF
147e83
@@ -102,7 +148,7 @@
147e83
 	cmpd	cr1,rNEG,rBITDIF
147e83
 	sub	rRTN,rWORD1,rWORD2
147e83
 	blt	cr1,L(equal)
147e83
-	sradi	rRTN,rRTN,63
147e83
+	sradi	rRTN,rRTN,63		/* must return an int.  */
147e83
 	ori	rRTN,rRTN,1
147e83
 	blr
147e83
 L(equal):
147e83
@@ -110,7 +156,7 @@
147e83
 	blr
147e83
 
147e83
 L(different):
147e83
-	ldu	rWORD1,-8(rSTR1)
147e83
+	ld	rWORD1,-8(rSTR1)
147e83
 	xor.	rBITDIF,rWORD1,rWORD2
147e83
 	sub	rRTN,rWORD1,rWORD2
147e83
 	blt	L(highbit)
147e83
@@ -118,11 +164,10 @@
147e83
 	ori	rRTN,rRTN,1
147e83
 	blr
147e83
 L(highbit):
147e83
-	srdi	rWORD2,rWORD2,56
147e83
-	srdi	rWORD1,rWORD1,56
147e83
-	sub	rRTN,rWORD1,rWORD2
147e83
+	sradi	rRTN,rWORD2,63
147e83
+	ori	rRTN,rRTN,1
147e83
 	blr
147e83
-
147e83
+#endif
147e83
 
147e83
 /* Oh well.  In this case, we just do a byte-by-byte comparison.  */
147e83
 	.align	4
147e83
diff -urN glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/strcmp.S glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/strcmp.S
147e83
--- glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/strcmp.S	2014-05-28 13:26:59.000000000 -0500
147e83
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/strcmp.S	2014-05-28 13:37:15.000000000 -0500
147e83
@@ -27,7 +27,7 @@
147e83
 EALIGN (BP_SYM(strcmp), 4, 0)
147e83
 	CALL_MCOUNT 2
147e83
 
147e83
-#define rTMP	r0
147e83
+#define rTMP2	r0
147e83
 #define rRTN	r3
147e83
 #define rSTR1	r3	/* first string arg */
147e83
 #define rSTR2	r4	/* second string arg */
147e83
@@ -46,6 +46,7 @@
147e83
 #define r7F7F	r8	/* constant 0x7f7f7f7f7f7f7f7f */
147e83
 #define rNEG	r9	/* ~(word in s1 | 0x7f7f7f7f7f7f7f7f) */
147e83
 #define rBITDIF	r10	/* bits that differ in s1 & s2 words */
147e83
+#define rTMP	r11
147e83
 
147e83
 	CHECK_BOUNDS_LOW (rSTR1, rTMP, rHIGH1)
147e83
 	CHECK_BOUNDS_LOW (rSTR2, rTMP, rHIGH2)
147e83
@@ -72,19 +73,66 @@
147e83
 	ldu	rWORD2, 8(rSTR2)
147e83
 L(g1):	add	rTMP, rFEFE, rWORD1
147e83
 	nor	rNEG, r7F7F, rWORD1
147e83
-
147e83
 	and.	rTMP, rTMP, rNEG
147e83
 	cmpd	cr1, rWORD1, rWORD2
147e83
 	beq+	L(g0)
147e83
-L(endstring):
147e83
+
147e83
 /* OK. We've hit the end of the string. We need to be careful that
147e83
    we don't compare two strings as different because of gunk beyond
147e83
    the end of the strings...  */
147e83
+#ifdef __LITTLE_ENDIAN__
147e83
+L(endstring):
147e83
+	addi    rTMP2, rTMP, -1
147e83
+	beq	cr1, L(equal)
147e83
+	andc    rTMP2, rTMP2, rTMP
147e83
+	rldimi	rTMP2, rTMP2, 1, 0
147e83
+	and	rWORD2, rWORD2, rTMP2	/* Mask off gunk.  */
147e83
+	and	rWORD1, rWORD1, rTMP2
147e83
+	cmpd	cr1, rWORD1, rWORD2
147e83
+	beq	cr1, L(equal)
147e83
+	xor	rBITDIF, rWORD1, rWORD2	/* rBITDIF has bits that differ.  */
147e83
+	neg	rNEG, rBITDIF
147e83
+	and	rNEG, rNEG, rBITDIF	/* rNEG has LS bit that differs.  */
147e83
+	cntlzd	rNEG, rNEG		/* bitcount of the bit.  */
147e83
+	andi.	rNEG, rNEG, 56		/* bitcount to LS byte that differs. */
147e83
+	sld	rWORD1, rWORD1, rNEG	/* shift left to clear MS bytes.  */
147e83
+	sld	rWORD2, rWORD2, rNEG
147e83
+	xor.	rBITDIF, rWORD1, rWORD2
147e83
+	sub	rRTN, rWORD1, rWORD2
147e83
+	blt-	L(highbit)
147e83
+	sradi	rRTN, rRTN, 63		/* must return an int.  */
147e83
+	ori	rRTN, rRTN, 1
147e83
+	blr
147e83
+L(equal):
147e83
+	li	rRTN, 0
147e83
+	blr
147e83
+
147e83
+L(different):
147e83
+	ld	rWORD1, -8(rSTR1)
147e83
+	xor	rBITDIF, rWORD1, rWORD2	/* rBITDIF has bits that differ.  */
147e83
+	neg	rNEG, rBITDIF
147e83
+	and	rNEG, rNEG, rBITDIF	/* rNEG has LS bit that differs.  */
147e83
+	cntlzd	rNEG, rNEG		/* bitcount of the bit.  */
147e83
+	andi.	rNEG, rNEG, 56		/* bitcount to LS byte that differs. */
147e83
+	sld	rWORD1, rWORD1, rNEG	/* shift left to clear MS bytes.  */
147e83
+	sld	rWORD2, rWORD2, rNEG
147e83
+	xor.	rBITDIF, rWORD1, rWORD2
147e83
+	sub	rRTN, rWORD1, rWORD2
147e83
+	blt-	L(highbit)
147e83
+	sradi	rRTN, rRTN, 63
147e83
+	ori	rRTN, rRTN, 1
147e83
+	blr
147e83
+L(highbit):
147e83
+	sradi	rRTN, rWORD2, 63
147e83
+	ori	rRTN, rRTN, 1
147e83
+	blr
147e83
+
147e83
+#else
147e83
+L(endstring):
147e83
 	and	rTMP, r7F7F, rWORD1
147e83
 	beq	cr1, L(equal)
147e83
 	add	rTMP, rTMP, r7F7F
147e83
 	xor.	rBITDIF, rWORD1, rWORD2
147e83
-
147e83
 	andc	rNEG, rNEG, rTMP
147e83
 	blt-	L(highbit)
147e83
 	cntlzd	rBITDIF, rBITDIF
147e83
@@ -93,7 +141,7 @@
147e83
 	cmpd	cr1, rNEG, rBITDIF
147e83
 	sub	rRTN, rWORD1, rWORD2
147e83
 	blt-	cr1, L(equal)
147e83
-	sradi	rRTN, rRTN, 63
147e83
+	sradi	rRTN, rRTN, 63		/* must return an int.  */
147e83
 	ori	rRTN, rRTN, 1
147e83
 	blr
147e83
 L(equal):
147e83
@@ -110,12 +158,11 @@
147e83
 	ori	rRTN, rRTN, 1
147e83
 	blr
147e83
 L(highbit):
147e83
-	srdi	rWORD2, rWORD2, 56
147e83
-	srdi	rWORD1, rWORD1, 56
147e83
-	sub	rRTN, rWORD1, rWORD2
147e83
+	sradi	rRTN, rWORD2, 63
147e83
+	ori	rRTN, rRTN, 1
147e83
 	/* GKM FIXME: check high bounds.  */
147e83
 	blr
147e83
-
147e83
+#endif
147e83
 
147e83
 /* Oh well.  In this case, we just do a byte-by-byte comparison.  */
147e83
 	.align 4
147e83
diff -urN glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/strncmp.S glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/strncmp.S
147e83
--- glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/strncmp.S	2014-05-28 13:26:59.000000000 -0500
147e83
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/strncmp.S	2014-05-28 13:38:31.000000000 -0500
147e83
@@ -27,7 +27,7 @@
147e83
 EALIGN (BP_SYM(strncmp), 4, 0)
147e83
 	CALL_MCOUNT 3
147e83
 
147e83
-#define rTMP	r0
147e83
+#define rTMP2	r0
147e83
 #define rRTN	r3
147e83
 #define rSTR1	r3	/* first string arg */
147e83
 #define rSTR2	r4	/* second string arg */
147e83
@@ -41,6 +41,7 @@
147e83
 #define r7F7F	r9	/* constant 0x7f7f7f7f7f7f7f7f */
147e83
 #define rNEG	r10	/* ~(word in s1 | 0x7f7f7f7f7f7f7f7f) */
147e83
 #define rBITDIF	r11	/* bits that differ in s1 & s2 words */
147e83
+#define rTMP	r12
147e83
 
147e83
 	dcbt	0,rSTR1
147e83
 	or	rTMP, rSTR2, rSTR1
147e83
@@ -81,13 +82,60 @@
147e83
 /* OK. We've hit the end of the string. We need to be careful that
147e83
    we don't compare two strings as different because of gunk beyond
147e83
    the end of the strings...  */
147e83
-	
147e83
+
147e83
+#ifdef __LITTLE_ENDIAN__
147e83
+L(endstring):
147e83
+	addi    rTMP2, rTMP, -1
147e83
+	beq	cr1, L(equal)
147e83
+	andc    rTMP2, rTMP2, rTMP
147e83
+	rldimi	rTMP2, rTMP2, 1, 0
147e83
+	and	rWORD2, rWORD2, rTMP2	/* Mask off gunk.  */
147e83
+	and	rWORD1, rWORD1, rTMP2
147e83
+	cmpd	cr1, rWORD1, rWORD2
147e83
+	beq	cr1, L(equal)
147e83
+	xor	rBITDIF, rWORD1, rWORD2	/* rBITDIF has bits that differ.  */
147e83
+	neg	rNEG, rBITDIF
147e83
+	and	rNEG, rNEG, rBITDIF	/* rNEG has LS bit that differs.  */
147e83
+	cntlzd	rNEG, rNEG		/* bitcount of the bit.  */
147e83
+	andi.	rNEG, rNEG, 56		/* bitcount to LS byte that differs. */
147e83
+	sld	rWORD1, rWORD1, rNEG	/* shift left to clear MS bytes.  */
147e83
+	sld	rWORD2, rWORD2, rNEG
147e83
+	xor.	rBITDIF, rWORD1, rWORD2
147e83
+	sub	rRTN, rWORD1, rWORD2
147e83
+	blt-	L(highbit)
147e83
+	sradi	rRTN, rRTN, 63		/* must return an int.  */
147e83
+	ori	rRTN, rRTN, 1
147e83
+	blr
147e83
+L(equal):
147e83
+	li	rRTN, 0
147e83
+	blr
147e83
+
147e83
+L(different):
147e83
+	ld	rWORD1, -8(rSTR1)
147e83
+	xor	rBITDIF, rWORD1, rWORD2	/* rBITDIF has bits that differ.  */
147e83
+	neg	rNEG, rBITDIF
147e83
+	and	rNEG, rNEG, rBITDIF	/* rNEG has LS bit that differs.  */
147e83
+	cntlzd	rNEG, rNEG		/* bitcount of the bit.  */
147e83
+	andi.	rNEG, rNEG, 56		/* bitcount to LS byte that differs. */
147e83
+	sld	rWORD1, rWORD1, rNEG	/* shift left to clear MS bytes.  */
147e83
+	sld	rWORD2, rWORD2, rNEG
147e83
+	xor.	rBITDIF, rWORD1, rWORD2
147e83
+	sub	rRTN, rWORD1, rWORD2
147e83
+	blt-	L(highbit)
147e83
+	sradi	rRTN, rRTN, 63
147e83
+	ori	rRTN, rRTN, 1
147e83
+	blr
147e83
+L(highbit):
147e83
+	sradi	rRTN, rWORD2, 63
147e83
+	ori	rRTN, rRTN, 1
147e83
+	blr
147e83
+
147e83
+#else
147e83
 L(endstring):
147e83
 	and	rTMP, r7F7F, rWORD1
147e83
 	beq	cr1, L(equal)
147e83
 	add	rTMP, rTMP, r7F7F
147e83
 	xor.	rBITDIF, rWORD1, rWORD2
147e83
-
147e83
 	andc	rNEG, rNEG, rTMP
147e83
 	blt-	L(highbit)
147e83
 	cntlzd	rBITDIF, rBITDIF
147e83
@@ -96,7 +144,7 @@
147e83
 	cmpd	cr1, rNEG, rBITDIF
147e83
 	sub	rRTN, rWORD1, rWORD2
147e83
 	blt-	cr1, L(equal)
147e83
-	sradi	rRTN, rRTN, 63
147e83
+	sradi	rRTN, rRTN, 63		/* must return an int.  */
147e83
 	ori	rRTN, rRTN, 1
147e83
 	blr
147e83
 L(equal):
147e83
@@ -104,7 +152,7 @@
147e83
 	blr
147e83
 
147e83
 L(different):
147e83
-	ldu	rWORD1, -8(rSTR1)
147e83
+	ld	rWORD1, -8(rSTR1)
147e83
 	xor.	rBITDIF, rWORD1, rWORD2
147e83
 	sub	rRTN, rWORD1, rWORD2
147e83
 	blt-	L(highbit)
147e83
@@ -112,11 +160,10 @@
147e83
 	ori	rRTN, rRTN, 1
147e83
 	blr
147e83
 L(highbit):
147e83
-	srdi	rWORD2, rWORD2, 56
147e83
-	srdi	rWORD1, rWORD1, 56
147e83
-	sub	rRTN, rWORD1, rWORD2
147e83
+	sradi	rRTN, rWORD2, 63
147e83
+	ori	rRTN, rRTN, 1
147e83
 	blr
147e83
-
147e83
+#endif
147e83
 
147e83
 /* Oh well.  In this case, we just do a byte-by-byte comparison.  */
147e83
 	.align 4