|
|
147e83 |
From 1e5a0d609f20a613e1e989802bbe479f61bed1ca Mon Sep 17 00:00:00 2001
|
|
|
147e83 |
From: Rajalakshmi Srinivasaraghavan <raji@linux.vnet.ibm.com>
|
|
|
147e83 |
Date: Thu, 1 Dec 2016 11:35:43 +0530
|
|
|
147e83 |
Subject: [PATCH] powerpc: strcmp optimization for power9
|
|
|
147e83 |
|
|
|
147e83 |
Vectorized loops are used for strings > 32B when compared
|
|
|
147e83 |
to power8 optimization.
|
|
|
147e83 |
|
|
|
147e83 |
Tested on power9 ppc64le simulator.
|
|
|
147e83 |
|
|
|
147e83 |
(cherry picked from commit 80ab6401a9bb566de940cc6a5fb7a6af650f17b9)
|
|
|
147e83 |
|
|
|
147e83 |
Conflicts:
|
|
|
147e83 |
sysdeps/powerpc/powerpc64/multiarch/strcmp.c
|
|
|
147e83 |
---
|
|
|
147e83 |
ChangeLog | 11 +
|
|
|
147e83 |
sysdeps/powerpc/powerpc64/multiarch/Makefile | 2 +-
|
|
|
147e83 |
.../powerpc/powerpc64/multiarch/ifunc-impl-list.c | 3 +
|
|
|
147e83 |
.../powerpc/powerpc64/multiarch/strcmp-power9.S | 40 +++
|
|
|
147e83 |
sysdeps/powerpc/powerpc64/multiarch/strcmp.c | 13 +-
|
|
|
147e83 |
sysdeps/powerpc/powerpc64/power9/strcmp.S | 278 +++++++++++++++++++++
|
|
|
147e83 |
6 files changed, 341 insertions(+), 6 deletions(-)
|
|
|
147e83 |
create mode 100644 sysdeps/powerpc/powerpc64/multiarch/strcmp-power9.S
|
|
|
147e83 |
create mode 100644 sysdeps/powerpc/powerpc64/power9/strcmp.S
|
|
|
147e83 |
|
|
|
147e83 |
diff --git a/ChangeLog b/ChangeLog
|
|
|
147e83 |
index 6d6aab3..57152b8 100644
|
|
|
147e83 |
diff --git a/sysdeps/powerpc/powerpc64/multiarch/Makefile b/sysdeps/powerpc/powerpc64/multiarch/Makefile
|
|
|
147e83 |
index e3ac285..2c83c22 100644
|
|
|
147e83 |
--- a/sysdeps/powerpc/powerpc64/multiarch/Makefile
|
|
|
147e83 |
+++ b/sysdeps/powerpc/powerpc64/multiarch/Makefile
|
|
|
147e83 |
@@ -16,7 +16,7 @@ sysdep_routines += memcpy-power7 memcpy-a2 memcpy-power6 memcpy-cell \
|
|
|
147e83 |
strncase-ppc64 strncase-power8 \
|
|
|
147e83 |
strcasestr-power8 strcasestr-ppc64 \
|
|
|
147e83 |
strcat-power8 strcat-power7 strcat-ppc64 \
|
|
|
147e83 |
- strcmp-power8 strcmp-power7 strcmp-ppc64 \
|
|
|
147e83 |
+ strcmp-power9 strcmp-power8 strcmp-power7 strcmp-ppc64 \
|
|
|
147e83 |
strcpy-power8 strcpy-power7 strcpy-ppc64 \
|
|
|
147e83 |
strcspn-power8 strcspn-ppc64 \
|
|
|
147e83 |
stpncpy-power8 stpncpy-power7 stpncpy-ppc64 \
|
|
|
147e83 |
diff --git a/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c b/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
|
|
|
147e83 |
index aabd7bc..404a226 100644
|
|
|
147e83 |
--- a/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
|
|
|
147e83 |
+++ b/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
|
|
|
147e83 |
@@ -311,6 +311,9 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
|
|
|
147e83 |
/* Support sysdeps/powerpc/powerpc64/multiarch/strcmp.c. */
|
|
|
147e83 |
IFUNC_IMPL (i, name, strcmp,
|
|
|
147e83 |
IFUNC_IMPL_ADD (array, i, strcmp,
|
|
|
147e83 |
+ hwcap2 & PPC_FEATURE2_ARCH_3_00,
|
|
|
147e83 |
+ __strcmp_power9)
|
|
|
147e83 |
+ IFUNC_IMPL_ADD (array, i, strcmp,
|
|
|
147e83 |
hwcap2 & PPC_FEATURE2_ARCH_2_07,
|
|
|
147e83 |
__strcmp_power8)
|
|
|
147e83 |
IFUNC_IMPL_ADD (array, i, strcmp,
|
|
|
147e83 |
diff --git a/sysdeps/powerpc/powerpc64/multiarch/strcmp-power9.S b/sysdeps/powerpc/powerpc64/multiarch/strcmp-power9.S
|
|
|
147e83 |
new file mode 100644
|
|
|
147e83 |
index 0000000..0a09e5b
|
|
|
147e83 |
--- /dev/null
|
|
|
147e83 |
+++ b/sysdeps/powerpc/powerpc64/multiarch/strcmp-power9.S
|
|
|
147e83 |
@@ -0,0 +1,40 @@
|
|
|
147e83 |
+/* Optimized strcmp implementation for POWER9/PPC64.
|
|
|
147e83 |
+ Copyright (C) 2016 Free Software Foundation, Inc.
|
|
|
147e83 |
+ This file is part of the GNU C Library.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
147e83 |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
147e83 |
+ License as published by the Free Software Foundation; either
|
|
|
147e83 |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
147e83 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
147e83 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
147e83 |
+ Lesser General Public License for more details.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
147e83 |
+ License along with the GNU C Library; if not, see
|
|
|
147e83 |
+ <http://www.gnu.org/licenses/>. */
|
|
|
147e83 |
+
|
|
|
147e83 |
+#include <sysdep.h>
|
|
|
147e83 |
+
|
|
|
147e83 |
+#undef EALIGN
|
|
|
147e83 |
+#define EALIGN(name, alignt, words) \
|
|
|
147e83 |
+ .section ".text"; \
|
|
|
147e83 |
+ ENTRY_2(__strcmp_power9) \
|
|
|
147e83 |
+ .align ALIGNARG(alignt); \
|
|
|
147e83 |
+ EALIGN_W_##words; \
|
|
|
147e83 |
+ BODY_LABEL(__strcmp_power9): \
|
|
|
147e83 |
+ cfi_startproc; \
|
|
|
147e83 |
+ LOCALENTRY(__strcmp_power9)
|
|
|
147e83 |
+
|
|
|
147e83 |
+#undef END
|
|
|
147e83 |
+#define END(name) \
|
|
|
147e83 |
+ cfi_endproc; \
|
|
|
147e83 |
+ TRACEBACK(__strcmp_power9) \
|
|
|
147e83 |
+ END_2(__strcmp_power9)
|
|
|
147e83 |
+
|
|
|
147e83 |
+#undef libc_hidden_builtin_def
|
|
|
147e83 |
+#define libc_hidden_builtin_def(name)
|
|
|
147e83 |
+
|
|
|
147e83 |
+#include <sysdeps/powerpc/powerpc64/power9/strcmp.S>
|
|
|
147e83 |
diff --git a/sysdeps/powerpc/powerpc64/multiarch/strcmp.c b/sysdeps/powerpc/powerpc64/multiarch/strcmp.c
|
|
|
147e83 |
index b45ba1f..7345f5a 100644
|
|
|
147e83 |
--- a/sysdeps/powerpc/powerpc64/multiarch/strcmp.c
|
|
|
147e83 |
+++ b/sysdeps/powerpc/powerpc64/multiarch/strcmp.c
|
|
|
147e83 |
@@ -24,11 +24,14 @@
|
|
|
147e83 |
extern __typeof (strcmp) __strcmp_ppc attribute_hidden;
|
|
|
147e83 |
extern __typeof (strcmp) __strcmp_power7 attribute_hidden;
|
|
|
147e83 |
extern __typeof (strcmp) __strcmp_power8 attribute_hidden;
|
|
|
147e83 |
+extern __typeof (strcmp) __strcmp_power9 attribute_hidden;
|
|
|
147e83 |
|
|
|
147e83 |
libc_ifunc (strcmp,
|
|
|
147e83 |
- (hwcap2 & PPC_FEATURE2_ARCH_2_07)
|
|
|
147e83 |
- ? __strcmp_power8 :
|
|
|
147e83 |
- (hwcap & PPC_FEATURE_HAS_VSX)
|
|
|
147e83 |
- ? __strcmp_power7
|
|
|
147e83 |
- : __strcmp_ppc);
|
|
|
147e83 |
+ (hwcap2 & PPC_FEATURE2_ARCH_3_00)
|
|
|
147e83 |
+ ? __strcmp_power9 :
|
|
|
147e83 |
+ (hwcap2 & PPC_FEATURE2_ARCH_2_07)
|
|
|
147e83 |
+ ? __strcmp_power8 :
|
|
|
147e83 |
+ (hwcap & PPC_FEATURE_HAS_VSX)
|
|
|
147e83 |
+ ? __strcmp_power7
|
|
|
147e83 |
+ : __strcmp_ppc);
|
|
|
147e83 |
#endif
|
|
|
147e83 |
diff --git a/sysdeps/powerpc/powerpc64/power9/strcmp.S b/sysdeps/powerpc/powerpc64/power9/strcmp.S
|
|
|
147e83 |
new file mode 100644
|
|
|
147e83 |
index 0000000..754d508
|
|
|
147e83 |
--- /dev/null
|
|
|
147e83 |
+++ b/sysdeps/powerpc/powerpc64/power9/strcmp.S
|
|
|
147e83 |
@@ -0,0 +1,278 @@
|
|
|
147e83 |
+/* Optimized strcmp implementation for PowerPC64/POWER9.
|
|
|
147e83 |
+ Copyright (C) 2016 Free Software Foundation, Inc.
|
|
|
147e83 |
+ This file is part of the GNU C Library.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
147e83 |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
147e83 |
+ License as published by the Free Software Foundation; either
|
|
|
147e83 |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
147e83 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
147e83 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
147e83 |
+ Lesser General Public License for more details.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
147e83 |
+ License along with the GNU C Library; if not, see
|
|
|
147e83 |
+ <http://www.gnu.org/licenses/>. */
|
|
|
147e83 |
+#ifdef __LITTLE_ENDIAN__
|
|
|
147e83 |
+#include <sysdep.h>
|
|
|
147e83 |
+
|
|
|
147e83 |
+/* Implements the function
|
|
|
147e83 |
+
|
|
|
147e83 |
+ int [r3] strcmp (const char *s1 [r3], const char *s2 [r4])
|
|
|
147e83 |
+
|
|
|
147e83 |
+ The implementation uses unaligned doubleword access for first 32 bytes
|
|
|
147e83 |
+ as in POWER8 patch and uses vectorised loops after that. */
|
|
|
147e83 |
+
|
|
|
147e83 |
+/* TODO: Change this to actual instructions when minimum binutils is upgraded
|
|
|
147e83 |
+ to 2.27. Macros are defined below for these newer instructions in order
|
|
|
147e83 |
+ to maintain compatibility. */
|
|
|
147e83 |
+# define VCTZLSBB(r,v) .long (0x10010602 | ((r)<<(32-11)) | ((v)<<(32-21)))
|
|
|
147e83 |
+
|
|
|
147e83 |
+# define VEXTUBRX(t,a,b) .long (0x1000070d \
|
|
|
147e83 |
+ | ((t)<<(32-11)) \
|
|
|
147e83 |
+ | ((a)<<(32-16)) \
|
|
|
147e83 |
+ | ((b)<<(32-21)) )
|
|
|
147e83 |
+
|
|
|
147e83 |
+# define VCMPNEZB(t,a,b) .long (0x10000507 \
|
|
|
147e83 |
+ | ((t)<<(32-11)) \
|
|
|
147e83 |
+ | ((a)<<(32-16)) \
|
|
|
147e83 |
+ | ((b)<<(32-21)) )
|
|
|
147e83 |
+
|
|
|
147e83 |
+/* Get 16 bytes for unaligned case.
|
|
|
147e83 |
+ reg1: Vector to hold next 16 bytes.
|
|
|
147e83 |
+ reg2: Address to read from.
|
|
|
147e83 |
+ reg3: Permute control vector. */
|
|
|
147e83 |
+# define GET16BYTES(reg1, reg2, reg3) \
|
|
|
147e83 |
+ lvx reg1, 0, reg2; \
|
|
|
147e83 |
+ vperm v8, v2, reg1, reg3; \
|
|
|
147e83 |
+ vcmpequb. v8, v0, v8; \
|
|
|
147e83 |
+ beq cr6, 1f; \
|
|
|
147e83 |
+ vspltisb v9, 0; \
|
|
|
147e83 |
+ b 2f; \
|
|
|
147e83 |
+ .align 4; \
|
|
|
147e83 |
+1: \
|
|
|
147e83 |
+ addi r6, reg2, 16; \
|
|
|
147e83 |
+ lvx v9, 0, r6; \
|
|
|
147e83 |
+2: \
|
|
|
147e83 |
+ vperm reg1, v9, reg1, reg3;
|
|
|
147e83 |
+
|
|
|
147e83 |
+/* TODO: change this to .machine power9 when the minimum required binutils
|
|
|
147e83 |
+ allows it. */
|
|
|
147e83 |
+
|
|
|
147e83 |
+ .machine power7
|
|
|
147e83 |
+EALIGN (strcmp, 4, 0)
|
|
|
147e83 |
+ li r0, 0
|
|
|
147e83 |
+
|
|
|
147e83 |
+ /* Check if [s1]+32 or [s2]+32 will cross a 4K page boundary using
|
|
|
147e83 |
+ the code:
|
|
|
147e83 |
+
|
|
|
147e83 |
+ (((size_t) s1) % PAGE_SIZE > (PAGE_SIZE - ITER_SIZE))
|
|
|
147e83 |
+
|
|
|
147e83 |
+ with PAGE_SIZE being 4096 and ITER_SIZE begin 32. */
|
|
|
147e83 |
+
|
|
|
147e83 |
+ rldicl r7, r3, 0, 52
|
|
|
147e83 |
+ rldicl r9, r4, 0, 52
|
|
|
147e83 |
+ cmpldi cr7, r7, 4096-32
|
|
|
147e83 |
+ bgt cr7, L(pagecross_check)
|
|
|
147e83 |
+ cmpldi cr5, r9, 4096-32
|
|
|
147e83 |
+ bgt cr5, L(pagecross_check)
|
|
|
147e83 |
+
|
|
|
147e83 |
+ /* For short strings up to 32 bytes, load both s1 and s2 using
|
|
|
147e83 |
+ unaligned dwords and compare. */
|
|
|
147e83 |
+ ld r8, 0(r3)
|
|
|
147e83 |
+ ld r10, 0(r4)
|
|
|
147e83 |
+ cmpb r12, r8, r0
|
|
|
147e83 |
+ cmpb r11, r8, r10
|
|
|
147e83 |
+ orc. r9, r12, r11
|
|
|
147e83 |
+ bne cr0, L(different_nocmpb)
|
|
|
147e83 |
+
|
|
|
147e83 |
+ ld r8, 8(r3)
|
|
|
147e83 |
+ ld r10, 8(r4)
|
|
|
147e83 |
+ cmpb r12, r8, r0
|
|
|
147e83 |
+ cmpb r11, r8, r10
|
|
|
147e83 |
+ orc. r9, r12, r11
|
|
|
147e83 |
+ bne cr0, L(different_nocmpb)
|
|
|
147e83 |
+
|
|
|
147e83 |
+ ld r8, 16(r3)
|
|
|
147e83 |
+ ld r10, 16(r4)
|
|
|
147e83 |
+ cmpb r12, r8, r0
|
|
|
147e83 |
+ cmpb r11, r8, r10
|
|
|
147e83 |
+ orc. r9, r12, r11
|
|
|
147e83 |
+ bne cr0, L(different_nocmpb)
|
|
|
147e83 |
+
|
|
|
147e83 |
+ ld r8, 24(r3)
|
|
|
147e83 |
+ ld r10, 24(r4)
|
|
|
147e83 |
+ cmpb r12, r8, r0
|
|
|
147e83 |
+ cmpb r11, r8, r10
|
|
|
147e83 |
+ orc. r9, r12, r11
|
|
|
147e83 |
+ bne cr0, L(different_nocmpb)
|
|
|
147e83 |
+
|
|
|
147e83 |
+ addi r7, r3, 32
|
|
|
147e83 |
+ addi r4, r4, 32
|
|
|
147e83 |
+
|
|
|
147e83 |
+L(align):
|
|
|
147e83 |
+ /* Now it has checked for first 32 bytes. */
|
|
|
147e83 |
+ vspltisb v0, 0
|
|
|
147e83 |
+ vspltisb v2, -1
|
|
|
147e83 |
+ lvsr v6, 0, r4 /* Compute mask. */
|
|
|
147e83 |
+ or r5, r4, r7
|
|
|
147e83 |
+ andi. r5, r5, 0xF
|
|
|
147e83 |
+ beq cr0, L(aligned)
|
|
|
147e83 |
+ andi. r5, r7, 0xF
|
|
|
147e83 |
+ beq cr0, L(s1_align)
|
|
|
147e83 |
+ lvsr v10, 0, r7 /* Compute mask. */
|
|
|
147e83 |
+
|
|
|
147e83 |
+ /* Both s1 and s2 are unaligned. */
|
|
|
147e83 |
+ GET16BYTES(v4, r7, v10)
|
|
|
147e83 |
+ GET16BYTES(v5, r4, v6)
|
|
|
147e83 |
+ VCMPNEZB(v7, v5, v4)
|
|
|
147e83 |
+ beq cr6, L(match)
|
|
|
147e83 |
+ b L(different)
|
|
|
147e83 |
+
|
|
|
147e83 |
+ /* Align s1 to qw and adjust s2 address. */
|
|
|
147e83 |
+ .align 4
|
|
|
147e83 |
+L(match):
|
|
|
147e83 |
+ clrldi r6, r7, 60
|
|
|
147e83 |
+ subfic r5, r6, 16
|
|
|
147e83 |
+ add r7, r7, r5
|
|
|
147e83 |
+ add r4, r4, r5
|
|
|
147e83 |
+ andi. r5, r4, 0xF
|
|
|
147e83 |
+ beq cr0, L(aligned)
|
|
|
147e83 |
+ lvsr v6, 0, r4
|
|
|
147e83 |
+ /* There are 2 loops depending on the input alignment.
|
|
|
147e83 |
+ Each loop gets 16 bytes from s1 and s2 and compares.
|
|
|
147e83 |
+ Loop until a mismatch or null occurs. */
|
|
|
147e83 |
+L(s1_align):
|
|
|
147e83 |
+ lvx v4, r7, r0
|
|
|
147e83 |
+ GET16BYTES(v5, r4, v6)
|
|
|
147e83 |
+ VCMPNEZB(v7, v5, v4)
|
|
|
147e83 |
+ addi r7, r7, 16
|
|
|
147e83 |
+ addi r4, r4, 16
|
|
|
147e83 |
+ bne cr6, L(different)
|
|
|
147e83 |
+
|
|
|
147e83 |
+ lvx v4, r7, r0
|
|
|
147e83 |
+ GET16BYTES(v5, r4, v6)
|
|
|
147e83 |
+ VCMPNEZB(v7, v5, v4)
|
|
|
147e83 |
+ addi r7, r7, 16
|
|
|
147e83 |
+ addi r4, r4, 16
|
|
|
147e83 |
+ bne cr6, L(different)
|
|
|
147e83 |
+
|
|
|
147e83 |
+ lvx v4, r7, r0
|
|
|
147e83 |
+ GET16BYTES(v5, r4, v6)
|
|
|
147e83 |
+ VCMPNEZB(v7, v5, v4)
|
|
|
147e83 |
+ addi r7, r7, 16
|
|
|
147e83 |
+ addi r4, r4, 16
|
|
|
147e83 |
+ bne cr6, L(different)
|
|
|
147e83 |
+
|
|
|
147e83 |
+ lvx v4, r7, r0
|
|
|
147e83 |
+ GET16BYTES(v5, r4, v6)
|
|
|
147e83 |
+ VCMPNEZB(v7, v5, v4)
|
|
|
147e83 |
+ addi r7, r7, 16
|
|
|
147e83 |
+ addi r4, r4, 16
|
|
|
147e83 |
+ beq cr6, L(s1_align)
|
|
|
147e83 |
+ b L(different)
|
|
|
147e83 |
+
|
|
|
147e83 |
+ .align 4
|
|
|
147e83 |
+L(aligned):
|
|
|
147e83 |
+ lvx v4, 0, r7
|
|
|
147e83 |
+ lvx v5, 0, r4
|
|
|
147e83 |
+ VCMPNEZB(v7, v5, v4)
|
|
|
147e83 |
+ addi r7, r7, 16
|
|
|
147e83 |
+ addi r4, r4, 16
|
|
|
147e83 |
+ bne cr6, L(different)
|
|
|
147e83 |
+
|
|
|
147e83 |
+ lvx v4, 0, r7
|
|
|
147e83 |
+ lvx v5, 0, r4
|
|
|
147e83 |
+ VCMPNEZB(v7, v5, v4)
|
|
|
147e83 |
+ addi r7, r7, 16
|
|
|
147e83 |
+ addi r4, r4, 16
|
|
|
147e83 |
+ bne cr6, L(different)
|
|
|
147e83 |
+
|
|
|
147e83 |
+ lvx v4, 0, r7
|
|
|
147e83 |
+ lvx v5, 0, r4
|
|
|
147e83 |
+ VCMPNEZB(v7, v5, v4)
|
|
|
147e83 |
+ addi r7, r7, 16
|
|
|
147e83 |
+ addi r4, r4, 16
|
|
|
147e83 |
+ bne cr6, L(different)
|
|
|
147e83 |
+
|
|
|
147e83 |
+ lvx v4, 0, r7
|
|
|
147e83 |
+ lvx v5, 0, r4
|
|
|
147e83 |
+ VCMPNEZB(v7, v5, v4)
|
|
|
147e83 |
+ addi r7, r7, 16
|
|
|
147e83 |
+ addi r4, r4, 16
|
|
|
147e83 |
+ beq cr6, L(aligned)
|
|
|
147e83 |
+
|
|
|
147e83 |
+ /* Calculate and return the difference. */
|
|
|
147e83 |
+L(different):
|
|
|
147e83 |
+ VCTZLSBB(r6, v7)
|
|
|
147e83 |
+ VEXTUBRX(r5, r6, v4)
|
|
|
147e83 |
+ VEXTUBRX(r4, r6, v5)
|
|
|
147e83 |
+ subf r3, r4, r5
|
|
|
147e83 |
+ extsw r3, r3
|
|
|
147e83 |
+ blr
|
|
|
147e83 |
+
|
|
|
147e83 |
+ .align 4
|
|
|
147e83 |
+L(different_nocmpb):
|
|
|
147e83 |
+ neg r3, r9
|
|
|
147e83 |
+ and r9, r9, r3
|
|
|
147e83 |
+ cntlzd r9, r9
|
|
|
147e83 |
+ subfic r9, r9, 63
|
|
|
147e83 |
+ srd r3, r8, r9
|
|
|
147e83 |
+ srd r10, r10, r9
|
|
|
147e83 |
+ rldicl r10, r10, 0, 56
|
|
|
147e83 |
+ rldicl r3, r3, 0, 56
|
|
|
147e83 |
+ subf r3, r10, r3
|
|
|
147e83 |
+ extsw r3, r3
|
|
|
147e83 |
+ blr
|
|
|
147e83 |
+
|
|
|
147e83 |
+ .align 4
|
|
|
147e83 |
+L(pagecross_check):
|
|
|
147e83 |
+ subfic r9, r9, 4096
|
|
|
147e83 |
+ subfic r7, r7, 4096
|
|
|
147e83 |
+ cmpld cr7, r7, r9
|
|
|
147e83 |
+ bge cr7, L(pagecross)
|
|
|
147e83 |
+ mr r7, r9
|
|
|
147e83 |
+
|
|
|
147e83 |
+ /* If unaligned 16 bytes reads across a 4K page boundary, it uses
|
|
|
147e83 |
+ a simple byte a byte comparison until the page alignment for s1
|
|
|
147e83 |
+ is reached. */
|
|
|
147e83 |
+L(pagecross):
|
|
|
147e83 |
+ add r7, r3, r7
|
|
|
147e83 |
+ subf r9, r3, r7
|
|
|
147e83 |
+ mtctr r9
|
|
|
147e83 |
+
|
|
|
147e83 |
+ .align 4
|
|
|
147e83 |
+L(pagecross_loop):
|
|
|
147e83 |
+ /* Loads a byte from s1 and s2, compare if *s1 is equal to *s2
|
|
|
147e83 |
+ and if *s1 is '\0'. */
|
|
|
147e83 |
+ lbz r9, 0(r3)
|
|
|
147e83 |
+ lbz r10, 0(r4)
|
|
|
147e83 |
+ addi r3, r3, 1
|
|
|
147e83 |
+ addi r4, r4, 1
|
|
|
147e83 |
+ cmplw cr7, r9, r10
|
|
|
147e83 |
+ cmpdi cr5, r9, r0
|
|
|
147e83 |
+ bne cr7, L(pagecross_ne)
|
|
|
147e83 |
+ beq cr5, L(pagecross_nullfound)
|
|
|
147e83 |
+ bdnz L(pagecross_loop)
|
|
|
147e83 |
+ b L(align)
|
|
|
147e83 |
+
|
|
|
147e83 |
+ .align 4
|
|
|
147e83 |
+L(pagecross_ne):
|
|
|
147e83 |
+ extsw r3, r9
|
|
|
147e83 |
+ mr r9, r10
|
|
|
147e83 |
+L(pagecross_retdiff):
|
|
|
147e83 |
+ subf r9, r9, r3
|
|
|
147e83 |
+ extsw r3, r9
|
|
|
147e83 |
+ blr
|
|
|
147e83 |
+
|
|
|
147e83 |
+ .align 4
|
|
|
147e83 |
+L(pagecross_nullfound):
|
|
|
147e83 |
+ li r3, 0
|
|
|
147e83 |
+ b L(pagecross_retdiff)
|
|
|
147e83 |
+END (strcmp)
|
|
|
147e83 |
+libc_hidden_builtin_def (strcmp)
|
|
|
147e83 |
+#else
|
|
|
147e83 |
+#include <sysdeps/powerpc/powerpc64/power8/strcmp.S>
|
|
|
147e83 |
+#endif
|
|
|
147e83 |
--
|
|
|
147e83 |
2.1.0
|
|
|
147e83 |
|