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