8ae002
From fabf4e24731762be7ed1fded89b536fe7150fe13 Mon Sep 17 00:00:00 2001
8ae002
From: Rajalakshmi Srinivasaraghavan <raji@linux.vnet.ibm.com>
8ae002
Date: Tue, 13 Dec 2016 10:53:42 +0530
8ae002
Subject: [PATCH] powerpc: strncmp optimization for power9
8ae002
8ae002
Vectorized loops are used for strings > 32B when compared
8ae002
to power8 optimization.
8ae002
8ae002
Tested on power9 ppc64le simulator.
8ae002
8ae002
(cherry picked from commit d89060d60307c84995177a6fba2ed80c96f6b914)
8ae002
8ae002
Conflicts:
8ae002
	sysdeps/powerpc/powerpc64/multiarch/strncmp.c
8ae002
---
8ae002
 ChangeLog                                          |  11 +
8ae002
 sysdeps/powerpc/powerpc64/multiarch/Makefile       |   3 +-
8ae002
 .../powerpc/powerpc64/multiarch/ifunc-impl-list.c  |   2 +
8ae002
 .../powerpc/powerpc64/multiarch/strncmp-power9.S   |  40 +++
8ae002
 sysdeps/powerpc/powerpc64/multiarch/strncmp.c      |  17 +-
8ae002
 sysdeps/powerpc/powerpc64/power9/strncmp.S         | 375 +++++++++++++++++++++
8ae002
 6 files changed, 440 insertions(+), 8 deletions(-)
8ae002
 create mode 100644 sysdeps/powerpc/powerpc64/multiarch/strncmp-power9.S
8ae002
 create mode 100644 sysdeps/powerpc/powerpc64/power9/strncmp.S
8ae002
8ae002
diff --git a/ChangeLog b/ChangeLog
8ae002
index 57152b8..0446268 100644
8ae002
diff --git a/sysdeps/powerpc/powerpc64/multiarch/Makefile b/sysdeps/powerpc/powerpc64/multiarch/Makefile
8ae002
index 2c83c22..2997b9d 100644
8ae002
--- a/sysdeps/powerpc/powerpc64/multiarch/Makefile
8ae002
+++ b/sysdeps/powerpc/powerpc64/multiarch/Makefile
8ae002
@@ -8,7 +8,8 @@ sysdep_routines += memcpy-power7 memcpy-a2 memcpy-power6 memcpy-cell \
8ae002
                   rawmemchr-ppc64 strlen-power7 strlen-ppc64 strnlen-power7 \
8ae002
                   strnlen-ppc64 strcasecmp-power7 strcasecmp_l-power7 \
8ae002
                   strncase-power7 strncase_l-power7 \
8ae002
-                  strncmp-power8 strncmp-power7 strncmp-power4 strncmp-ppc64 \
8ae002
+                  strncmp-power9 strncmp-power8 strncmp-power7 \
8ae002
+                  strncmp-power4 strncmp-ppc64 \
8ae002
                   strchr-power7 strchr-ppc64 \
8ae002
                   strchrnul-power7 strchrnul-ppc64 wcschr-power7 \
8ae002
                   wcschr-power6 wcschr-ppc64 wcsrchr-power7 wcsrchr-power6 \
8ae002
diff --git a/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c b/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
8ae002
index 404a226..a140583 100644
8ae002
--- a/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
8ae002
+++ b/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
8ae002
@@ -110,6 +110,8 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
8ae002
 
8ae002
   /* Support sysdeps/powerpc/powerpc64/multiarch/strncmp.c.  */
8ae002
   IFUNC_IMPL (i, name, strncmp,
8ae002
+             IFUNC_IMPL_ADD (array, i, strncmp, hwcap2 & PPC_FEATURE2_ARCH_3_00,
8ae002
+                             __strncmp_power9)
8ae002
               IFUNC_IMPL_ADD (array, i, strncmp, hwcap2 & PPC_FEATURE2_ARCH_2_07,
8ae002
                               __strncmp_power8)
8ae002
              IFUNC_IMPL_ADD (array, i, strncmp, hwcap & PPC_FEATURE_HAS_VSX,
8ae002
diff --git a/sysdeps/powerpc/powerpc64/multiarch/strncmp-power9.S b/sysdeps/powerpc/powerpc64/multiarch/strncmp-power9.S
8ae002
new file mode 100644
8ae002
index 0000000..2f8d0c4
8ae002
--- /dev/null
8ae002
+++ b/sysdeps/powerpc/powerpc64/multiarch/strncmp-power9.S
8ae002
@@ -0,0 +1,40 @@
8ae002
+/* Copyright (C) 2016 Free Software Foundation, Inc.
8ae002
+   This file is part of the GNU C Library.
8ae002
+
8ae002
+   The GNU C Library is free software; you can redistribute it and/or
8ae002
+   modify it under the terms of the GNU Lesser General Public
8ae002
+   License as published by the Free Software Foundation; either
8ae002
+   version 2.1 of the License, or (at your option) any later version.
8ae002
+
8ae002
+   The GNU C Library is distributed in the hope that it will be useful,
8ae002
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
8ae002
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
8ae002
+   Lesser General Public License for more details.
8ae002
+
8ae002
+   You should have received a copy of the GNU Lesser General Public
8ae002
+   License along with the GNU C Library; if not, see
8ae002
+   <http://www.gnu.org/licenses/>.  */
8ae002
+
8ae002
+#include <sysdep.h>
8ae002
+
8ae002
+#undef EALIGN
8ae002
+#define EALIGN(name,alignt,words)				\
8ae002
+  .section ".text";						\
8ae002
+  ENTRY_2(__strncmp_power9)					\
8ae002
+  .align ALIGNARG(alignt);					\
8ae002
+  EALIGN_W_##words;						\
8ae002
+  BODY_LABEL(__strncmp_power9):					\
8ae002
+  cfi_startproc;						\
8ae002
+  LOCALENTRY(__strncmp_power9)
8ae002
+
8ae002
+#undef END
8ae002
+#define END(name)						\
8ae002
+  cfi_endproc;							\
8ae002
+  TRACEBACK(__strncmp_power9)					\
8ae002
+  END_2(__strncmp_power9)
8ae002
+
8ae002
+
8ae002
+#undef libc_hidden_builtin_def
8ae002
+#define libc_hidden_builtin_def(name)
8ae002
+
8ae002
+#include <sysdeps/powerpc/powerpc64/power9/strncmp.S>
8ae002
diff --git a/sysdeps/powerpc/powerpc64/multiarch/strncmp.c b/sysdeps/powerpc/powerpc64/multiarch/strncmp.c
8ae002
index 9b6a659..3859cbc 100644
8ae002
--- a/sysdeps/powerpc/powerpc64/multiarch/strncmp.c
8ae002
+++ b/sysdeps/powerpc/powerpc64/multiarch/strncmp.c
8ae002
@@ -26,15 +26,18 @@ extern __typeof (strncmp) __strncmp_ppc attribute_hidden;
8ae002
 extern __typeof (strncmp) __strncmp_power4 attribute_hidden;
8ae002
 extern __typeof (strncmp) __strncmp_power7 attribute_hidden;
8ae002
 extern __typeof (strncmp) __strncmp_power8 attribute_hidden;
8ae002
+extern __typeof (strncmp) __strncmp_power9 attribute_hidden;
8ae002
 
8ae002
 /* Avoid DWARF definition DIE on ifunc symbol so that GDB can handle
8ae002
    ifunc symbol properly.  */
8ae002
 libc_ifunc (strncmp,
8ae002
-            (hwcap2 & PPC_FEATURE2_ARCH_2_07)
8ae002
-            ? __strncmp_power8 :
8ae002
-              (hwcap & PPC_FEATURE_HAS_VSX)
8ae002
-              ? __strncmp_power7 :
8ae002
-		(hwcap & PPC_FEATURE_POWER4)
8ae002
-		? __strncmp_power4
8ae002
-            : __strncmp_ppc);
8ae002
+	    (hwcap2 & PPC_FEATURE2_ARCH_3_00)
8ae002
+	      ? __strncmp_power9 :
8ae002
+	    (hwcap2 & PPC_FEATURE2_ARCH_2_07)
8ae002
+	      ? __strncmp_power8 :
8ae002
+	    (hwcap & PPC_FEATURE_HAS_VSX)
8ae002
+	      ? __strncmp_power7 :
8ae002
+	    (hwcap & PPC_FEATURE_POWER4)
8ae002
+	      ? __strncmp_power4
8ae002
+	    : __strncmp_ppc);
8ae002
 #endif
8ae002
diff --git a/sysdeps/powerpc/powerpc64/power9/strncmp.S b/sysdeps/powerpc/powerpc64/power9/strncmp.S
8ae002
new file mode 100644
8ae002
index 0000000..3f2fa75
8ae002
--- /dev/null
8ae002
+++ b/sysdeps/powerpc/powerpc64/power9/strncmp.S
8ae002
@@ -0,0 +1,375 @@
8ae002
+/* Optimized strncmp implementation for PowerPC64/POWER9.
8ae002
+   Copyright (C) 2016 Free Software Foundation, Inc.
8ae002
+   This file is part of the GNU C Library.
8ae002
+
8ae002
+   The GNU C Library is free software; you can redistribute it and/or
8ae002
+   modify it under the terms of the GNU Lesser General Public
8ae002
+   License as published by the Free Software Foundation; either
8ae002
+   version 2.1 of the License, or (at your option) any later version.
8ae002
+
8ae002
+   The GNU C Library is distributed in the hope that it will be useful,
8ae002
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
8ae002
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
8ae002
+   Lesser General Public License for more details.
8ae002
+
8ae002
+   You should have received a copy of the GNU Lesser General Public
8ae002
+   License along with the GNU C Library; if not, see
8ae002
+   <http://www.gnu.org/licenses/>.  */
8ae002
+#ifdef __LITTLE_ENDIAN__
8ae002
+#include <sysdep.h>
8ae002
+
8ae002
+/* Implements the function
8ae002
+
8ae002
+   int [r3] strncmp (const char *s1 [r3], const char *s2 [r4], size_t [r5] n)
8ae002
+
8ae002
+   The implementation uses unaligned doubleword access to avoid specialized
8ae002
+   code paths depending of data alignment for first 32 bytes and uses
8ae002
+   vectorised loops after that.  */
8ae002
+
8ae002
+/* TODO: Change this to actual instructions when minimum binutils is upgraded
8ae002
+   to 2.27. Macros are defined below for these newer instructions in order
8ae002
+   to maintain compatibility.  */
8ae002
+# define VCTZLSBB(r,v) .long (0x10010602 | ((r)<<(32-11)) | ((v)<<(32-21)))
8ae002
+
8ae002
+# define VEXTUBRX(t,a,b) .long (0x1000070d \
8ae002
+				| ((t)<<(32-11))  \
8ae002
+				| ((a)<<(32-16))  \
8ae002
+				| ((b)<<(32-21)) )
8ae002
+
8ae002
+# define VCMPNEZB(t,a,b) .long (0x10000507 \
8ae002
+				| ((t)<<(32-11))  \
8ae002
+				| ((a)<<(32-16))  \
8ae002
+				| ((b)<<(32-21)) )
8ae002
+
8ae002
+/* Get 16 bytes for unaligned case.
8ae002
+   reg1: Vector to hold next 16 bytes.
8ae002
+   reg2: Address to read from.
8ae002
+   reg3: Permute control vector.  */
8ae002
+# define GET16BYTES(reg1, reg2, reg3) \
8ae002
+	lvx	reg1, 0, reg2; \
8ae002
+	vperm	v8, v2, reg1, reg3; \
8ae002
+	vcmpequb.	v8, v0, v8; \
8ae002
+	beq	cr6, 1f; \
8ae002
+	vspltisb	v9, 0; \
8ae002
+	b	2f; \
8ae002
+	.align 4; \
8ae002
+1: \
8ae002
+	cmplw	cr6, r5, r11; \
8ae002
+	ble	cr6, 2f; \
8ae002
+	addi	r6, reg2, 16; \
8ae002
+	lvx	v9, 0, r6; \
8ae002
+2: \
8ae002
+	vperm	reg1, v9, reg1, reg3;
8ae002
+
8ae002
+/* TODO: change this to .machine power9 when minimum binutils
8ae002
+   is upgraded to 2.27.  */
8ae002
+	.machine  power7
8ae002
+EALIGN (strncmp, 4, 0)
8ae002
+	/* Check if size is 0.  */
8ae002
+	cmpdi	cr0, r5, 0
8ae002
+	beq	cr0, L(ret0)
8ae002
+	li	r0, 0
8ae002
+
8ae002
+	/* Check if [s1]+32 or [s2]+32 will cross a 4K page boundary using
8ae002
+	   the code:
8ae002
+
8ae002
+	    (((size_t) s1) % PAGE_SIZE > (PAGE_SIZE - ITER_SIZE))
8ae002
+
8ae002
+	   with PAGE_SIZE being 4096 and ITER_SIZE begin 32.  */
8ae002
+	rldicl	r8, r3, 0, 52
8ae002
+	cmpldi	cr7, r8, 4096-32
8ae002
+	bgt	cr7, L(pagecross)
8ae002
+	rldicl	r9, r4, 0, 52
8ae002
+	cmpldi	cr7, r9, 4096-32
8ae002
+	bgt	cr7, L(pagecross)
8ae002
+
8ae002
+	/* For short strings up to 32 bytes, load both s1 and s2 using
8ae002
+	   unaligned dwords and compare.  */
8ae002
+
8ae002
+	ld	r7, 0(r3)
8ae002
+	ld	r9, 0(r4)
8ae002
+	li	r8, 0
8ae002
+	cmpb	r8, r7, r8
8ae002
+	cmpb	r6, r7, r9
8ae002
+	orc.	r8, r8, r6
8ae002
+	bne	cr0, L(different1)
8ae002
+
8ae002
+	/* If the strings compared are equal, but size is less or equal
8ae002
+	   to 8, return 0.  */
8ae002
+	cmpldi	cr7, r5, 8
8ae002
+	li	r9, 0
8ae002
+	ble	cr7, L(ret1)
8ae002
+	addi	r5, r5, -8
8ae002
+
8ae002
+	ld	r7, 8(r3)
8ae002
+	ld	r9, 8(r4)
8ae002
+	cmpb	r8, r7, r8
8ae002
+	cmpb	r6, r7, r9
8ae002
+	orc.	r8, r8, r6
8ae002
+	bne	cr0, L(different1)
8ae002
+	cmpldi	cr7, r5, 8
8ae002
+	mr	r9, r8
8ae002
+	ble	cr7, L(ret1)
8ae002
+	/* Update pointers and size.  */
8ae002
+	addi	r5, r5, -8
8ae002
+	addi	r3, r3, 16
8ae002
+	addi	r4, r4, 16
8ae002
+
8ae002
+	ld	r7, 0(r3)
8ae002
+	ld	r9, 0(r4)
8ae002
+	li	r8, 0
8ae002
+	cmpb	r8, r7, r8
8ae002
+	cmpb	r6, r7, r9
8ae002
+	orc.	r8, r8, r6
8ae002
+	bne	cr0, L(different1)
8ae002
+	cmpldi	cr7, r5, 8
8ae002
+	li	r9, 0
8ae002
+	ble	cr7, L(ret1)
8ae002
+	addi	r5, r5, -8
8ae002
+
8ae002
+	ld	r7, 8(r3)
8ae002
+	ld	r9, 8(r4)
8ae002
+	cmpb	r8, r7, r8
8ae002
+	cmpb	r6, r7, r9
8ae002
+	orc.	r8, r8, r6
8ae002
+	bne	cr0, L(different1)
8ae002
+	cmpldi	cr7, r5, 8
8ae002
+	mr	r9, r8
8ae002
+	ble	cr7, L(ret1)
8ae002
+
8ae002
+	/* Update pointers and size.  */
8ae002
+	addi	r5, r5, -8
8ae002
+	addi	r3, r3, 16
8ae002
+	addi	r4, r4, 16
8ae002
+L(align):
8ae002
+	/* Now it has checked for first 32 bytes, align source1 to doubleword
8ae002
+	   and adjust source2 address.  */
8ae002
+	vspltisb	v0, 0
8ae002
+	vspltisb	v2, -1
8ae002
+	or	r6, r4, r3
8ae002
+	andi.	r6, r6, 0xF
8ae002
+	beq	cr0, L(aligned)
8ae002
+	lvsr	v6, 0, r4   /* Compute mask.  */
8ae002
+	clrldi	r6, r4, 60
8ae002
+	subfic	r11, r6, 16
8ae002
+	andi.	r6, r3, 0xF
8ae002
+	beq	cr0, L(s1_align)
8ae002
+	/* Both s1 and s2 are unaligned.  */
8ae002
+	GET16BYTES(v5, r4, v6)
8ae002
+	lvsr	v10, 0, r3   /* Compute mask.  */
8ae002
+	clrldi	r6, r3, 60
8ae002
+	subfic	r11, r6, 16
8ae002
+	GET16BYTES(v4, r3, v10)
8ae002
+	VCMPNEZB(v7, v5, v4)
8ae002
+	beq	cr6, L(match)
8ae002
+	b	L(different)
8ae002
+
8ae002
+	/* Align s1 to qw and adjust s2 address.  */
8ae002
+	.align  4
8ae002
+L(match):
8ae002
+	cmpldi	cr7, r5, 16
8ae002
+	ble	cr7, L(ret0)
8ae002
+	subf	r5, r11, r5
8ae002
+	add	r3, r3, r11
8ae002
+	add	r4, r4, r11
8ae002
+	andi.	r11, r4, 0xF
8ae002
+	beq	cr0, L(aligned)
8ae002
+	lvsr	v6, 0, r4
8ae002
+	clrldi	r6, r4, 60
8ae002
+	subfic	r11, r6, 16
8ae002
+	/* There are 2 loops depending on the input alignment.
8ae002
+	   Each loop gets 16 bytes from s1 and s2, checks for null
8ae002
+	   and compares them. Loops until a mismatch or  null occurs.  */
8ae002
+L(s1_align):
8ae002
+	lvx	v4, 0, r3
8ae002
+	GET16BYTES(v5, r4, v6)
8ae002
+	VCMPNEZB(v7, v5, v4)
8ae002
+	bne	cr6, L(different)
8ae002
+	cmpldi	cr7, r5, 16
8ae002
+	ble	cr7, L(ret0)
8ae002
+	addi	r5, r5, -16
8ae002
+	addi	r3, r3, 16
8ae002
+	addi	r4, r4, 16
8ae002
+
8ae002
+	lvx	v4, 0, r3
8ae002
+	GET16BYTES(v5, r4, v6)
8ae002
+	VCMPNEZB(v7, v5, v4)
8ae002
+	bne	cr6, L(different)
8ae002
+	cmpldi	cr7, r5, 16
8ae002
+	ble	cr7, L(ret0)
8ae002
+	addi	r5, r5, -16
8ae002
+	addi	r3, r3, 16
8ae002
+	addi	r4, r4, 16
8ae002
+
8ae002
+	lvx	v4, 0, r3
8ae002
+	GET16BYTES(v5, r4, v6)
8ae002
+	VCMPNEZB(v7, v5, v4)
8ae002
+	bne	cr6, L(different)
8ae002
+	cmpldi	cr7, r5, 16
8ae002
+	ble	cr7, L(ret0)
8ae002
+	addi	r5, r5, -16
8ae002
+	addi	r3, r3, 16
8ae002
+	addi	r4, r4, 16
8ae002
+
8ae002
+	lvx	v4, 0, r3
8ae002
+	GET16BYTES(v5, r4, v6)
8ae002
+	VCMPNEZB(v7, v5, v4)
8ae002
+	bne	cr6, L(different)
8ae002
+	cmpldi	cr7, r5, 16
8ae002
+	ble	cr7, L(ret0)
8ae002
+	addi	r5, r5, -16
8ae002
+	addi	r3, r3, 16
8ae002
+	addi	r4, r4, 16
8ae002
+	b	L(s1_align)
8ae002
+	.align  4
8ae002
+L(aligned):
8ae002
+	lvx	v4, 0, r3
8ae002
+	lvx	v5, 0, r4
8ae002
+	VCMPNEZB(v7, v5, v4)
8ae002
+	bne	cr6, L(different)
8ae002
+	cmpldi	cr7, r5, 16
8ae002
+	ble	cr7, L(ret0)
8ae002
+	addi	r5, r5, -16
8ae002
+	addi	r3, r3, 16
8ae002
+	addi	r4, r4, 16
8ae002
+
8ae002
+	lvx	v4, 0, r3
8ae002
+	lvx	v5, 0, r4
8ae002
+	VCMPNEZB(v7, v5, v4)
8ae002
+	bne	cr6, L(different)
8ae002
+	cmpldi	cr7, r5, 16
8ae002
+	ble	cr7, L(ret0)
8ae002
+	addi	r5, r5, -16
8ae002
+	addi	r3, r3, 16
8ae002
+	addi	r4, r4, 16
8ae002
+
8ae002
+	lvx	v4, 0, r3
8ae002
+	lvx	v5, 0, r4
8ae002
+	VCMPNEZB(v7, v5, v4)
8ae002
+	bne	cr6, L(different)
8ae002
+	cmpldi	cr7, r5, 16
8ae002
+	ble	cr7, L(ret0)
8ae002
+	addi	r5, r5, -16
8ae002
+	addi	r3, r3, 16
8ae002
+	addi	r4, r4, 16
8ae002
+
8ae002
+	lvx	v4, 0, r3
8ae002
+	lvx	v5, 0, r4
8ae002
+	VCMPNEZB(v7, v5, v4)
8ae002
+	bne	cr6, L(different)
8ae002
+	cmpldi	cr7, r5, 16
8ae002
+	ble	cr7, L(ret0)
8ae002
+	addi	r5, r5, -16
8ae002
+	addi	r3, r3, 16
8ae002
+	addi	r4, r4, 16
8ae002
+	b	L(aligned)
8ae002
+	/* Calculate and return the difference.  */
8ae002
+L(different):
8ae002
+	VCTZLSBB(r6, v7)
8ae002
+	cmplw	cr7, r5, r6
8ae002
+	ble	cr7, L(ret0)
8ae002
+	VEXTUBRX(r5, r6, v4)
8ae002
+	VEXTUBRX(r4, r6, v5)
8ae002
+	subf	r3, r4, r5
8ae002
+	extsw	r3, r3
8ae002
+	blr
8ae002
+
8ae002
+	.align 4
8ae002
+L(ret0):
8ae002
+	li	r9, 0
8ae002
+L(ret1):
8ae002
+	mr	r3, r9
8ae002
+	blr
8ae002
+
8ae002
+	/* The code now checks if r8 and r5 are different by issuing a
8ae002
+	   cmpb and shifts the result based on its output:
8ae002
+
8ae002
+	  leadzero = (__builtin_ffsl (z1) - 1);
8ae002
+	  leadzero = leadzero > (n-1)*8 ? (n-1)*8 : leadzero;
8ae002
+	  r1 = (r1 >> leadzero) & 0xFFUL;
8ae002
+	  r2 = (r2 >> leadzero) & 0xFFUL;
8ae002
+	  return r1 - r2;  */
8ae002
+
8ae002
+	.align 4
8ae002
+L(different1):
8ae002
+	neg	r11, r8
8ae002
+	sldi	r5, r5, 3
8ae002
+	and	r8, r11, r8
8ae002
+	addi	r5, r5, -8
8ae002
+	cntlzd	r8, r8
8ae002
+	subfic	r8, r8, 63
8ae002
+	extsw 	r8, r8
8ae002
+	cmpld	cr7, r8, r5
8ae002
+	ble	cr7, L(different2)
8ae002
+	mr	r8, r5
8ae002
+L(different2):
8ae002
+	extsw	r8, r8
8ae002
+	srd	r7, r7, r8
8ae002
+	srd	r9, r9, r8
8ae002
+	rldicl	r3, r7, 0, 56
8ae002
+	rldicl	r9, r9, 0, 56
8ae002
+	subf	r9, r9, 3
8ae002
+	extsw	r9, r9
8ae002
+	mr	r3, r9
8ae002
+	blr
8ae002
+
8ae002
+	/* If unaligned 16 bytes reads across a 4K page boundary, it uses
8ae002
+	   a simple byte a byte comparison until the page alignment for s1
8ae002
+	   is reached.  */
8ae002
+	.align 4
8ae002
+L(pagecross):
8ae002
+	lbz	r7, 0(r3)
8ae002
+	lbz	r9, 0(r4)
8ae002
+	subfic	r8, r8,4095
8ae002
+	cmplw	cr7, r9, r7
8ae002
+	bne	cr7, L(byte_ne_3)
8ae002
+	cmpdi	cr7, r9, 0
8ae002
+	beq	cr7, L(byte_ne_0)
8ae002
+	addi	r5, r5, -1
8ae002
+	subf	r7, r8, r5
8ae002
+	subf	r9, r7, r5
8ae002
+	addi	r9, r9, 1
8ae002
+	mtctr	r9
8ae002
+	b	L(pagecross_loop1)
8ae002
+
8ae002
+	.align 4
8ae002
+L(pagecross_loop0):
8ae002
+	beq	cr7, L(ret0)
8ae002
+	lbz	r9, 0(r3)
8ae002
+	lbz	r8, 0(r4)
8ae002
+	addi	r5, r5, -1
8ae002
+	cmplw	cr7, r9, r8
8ae002
+	cmpdi	cr5, r9, 0
8ae002
+	bne	cr7, L(byte_ne_2)
8ae002
+	beq	cr5, L(byte_ne_0)
8ae002
+L(pagecross_loop1):
8ae002
+	cmpdi	cr7, r5, 0
8ae002
+	addi	r3, r3, 1
8ae002
+	addi	r4, r4, 1
8ae002
+	bdnz	L(pagecross_loop0)
8ae002
+	cmpdi	cr7, r7, 0
8ae002
+	li	r9, 0
8ae002
+	bne+	cr7, L(align)
8ae002
+	b	L(ret1)
8ae002
+
8ae002
+	.align 4
8ae002
+L(byte_ne_0):
8ae002
+	li	r7, 0
8ae002
+L(byte_ne_1):
8ae002
+	subf	r9, r9, r7
8ae002
+	extsw	r9, r9
8ae002
+	b	L(ret1)
8ae002
+
8ae002
+	.align 4
8ae002
+L(byte_ne_2):
8ae002
+	extsw	r7, r9
8ae002
+	mr	r9, r8
8ae002
+	b	L(byte_ne_1)
8ae002
+L(byte_ne_3):
8ae002
+	extsw	r7, r7
8ae002
+	b	L(byte_ne_1)
8ae002
+END(strncmp)
8ae002
+libc_hidden_builtin_def(strncmp)
8ae002
+#else
8ae002
+#include <sysdeps/powerpc/powerpc64/power8/strncmp.S>
8ae002
+#endif
8ae002
-- 
8ae002
2.1.0
8ae002