|
|
446cf2 |
commit 75870237ff3bb363447b03f4b0af100227570910
|
|
|
446cf2 |
Author: Sunil K Pandey <skpgkp1@gmail.com>
|
|
|
446cf2 |
Date: Fri Jun 12 08:57:16 2020 -0700
|
|
|
446cf2 |
|
|
|
446cf2 |
Fix avx2 strncmp offset compare condition check [BZ #25933]
|
|
|
446cf2 |
|
|
|
446cf2 |
strcmp-avx2.S: In avx2 strncmp function, strings are compared in
|
|
|
446cf2 |
chunks of 4 vector size(i.e. 32x4=128 byte for avx2). After first 4
|
|
|
446cf2 |
vector size comparison, code must check whether it already passed
|
|
|
446cf2 |
the given offset. This patch implement avx2 offset check condition
|
|
|
446cf2 |
for strncmp function, if both string compare same for first 4 vector
|
|
|
446cf2 |
size.
|
|
|
446cf2 |
|
|
|
446cf2 |
diff --git a/sysdeps/x86_64/multiarch/strcmp-avx2.S b/sysdeps/x86_64/multiarch/strcmp-avx2.S
|
|
|
446cf2 |
index 5f88a68262..d42b04b54f 100644
|
|
|
446cf2 |
--- a/sysdeps/x86_64/multiarch/strcmp-avx2.S
|
|
|
446cf2 |
+++ b/sysdeps/x86_64/multiarch/strcmp-avx2.S
|
|
|
446cf2 |
@@ -591,7 +591,14 @@ L(loop_cross_page_2_vec):
|
|
|
446cf2 |
movl $(PAGE_SIZE / (VEC_SIZE * 4) - 1), %esi
|
|
|
446cf2 |
|
|
|
446cf2 |
testq %rdi, %rdi
|
|
|
446cf2 |
+# ifdef USE_AS_STRNCMP
|
|
|
446cf2 |
+ /* At this point, if %rdi value is 0, it already tested
|
|
|
446cf2 |
+ VEC_SIZE*4+%r10 byte starting from %rax. This label
|
|
|
446cf2 |
+ checks whether strncmp maximum offset reached or not. */
|
|
|
446cf2 |
+ je L(string_nbyte_offset_check)
|
|
|
446cf2 |
+# else
|
|
|
446cf2 |
je L(back_to_loop)
|
|
|
446cf2 |
+# endif
|
|
|
446cf2 |
tzcntq %rdi, %rcx
|
|
|
446cf2 |
addq %r10, %rcx
|
|
|
446cf2 |
/* Adjust for number of bytes skipped. */
|
|
|
446cf2 |
@@ -627,6 +634,14 @@ L(loop_cross_page_2_vec):
|
|
|
446cf2 |
VZEROUPPER
|
|
|
446cf2 |
ret
|
|
|
446cf2 |
|
|
|
446cf2 |
+# ifdef USE_AS_STRNCMP
|
|
|
446cf2 |
+L(string_nbyte_offset_check):
|
|
|
446cf2 |
+ leaq (VEC_SIZE * 4)(%r10), %r10
|
|
|
446cf2 |
+ cmpq %r10, %r11
|
|
|
446cf2 |
+ jbe L(zero)
|
|
|
446cf2 |
+ jmp L(back_to_loop)
|
|
|
446cf2 |
+# endif
|
|
|
446cf2 |
+
|
|
|
446cf2 |
.p2align 4
|
|
|
446cf2 |
L(cross_page_loop):
|
|
|
446cf2 |
/* Check one byte/dword at a time. */
|