From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1827) id CF33A3851C33; Tue, 6 Oct 2020 18:59:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CF33A3851C33 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Tulio Magno Quites Machado Filho To: glibc-cvs@sourceware.org Subject: [glibc/ibm/2.28/master] Fix avx2 strncmp offset compare condition check [BZ #25933] X-Act-Checkin: glibc X-Git-Author: Sunil K Pandey X-Git-Refname: refs/heads/ibm/2.28/master X-Git-Oldrev: 21344a3d62a29406fddeec069ee4eb3c341369f9 X-Git-Newrev: 23db5555eb914c6a0228ecf5dc13c13be5d8dbd7 Message-Id: <20201006185913.CF33A3851C33@sourceware.org> Date: Tue, 6 Oct 2020 18:59:13 +0000 (GMT) X-BeenThere: glibc-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Glibc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Oct 2020 18:59:13 -0000 https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=23db5555eb914c6a0228ecf5dc13c13be5d8dbd7 commit 23db5555eb914c6a0228ecf5dc13c13be5d8dbd7 Author: Sunil K Pandey Date: Fri Jun 12 08:57:16 2020 -0700 Fix avx2 strncmp offset compare condition check [BZ #25933] strcmp-avx2.S: In avx2 strncmp function, strings are compared in chunks of 4 vector size(i.e. 32x4=128 byte for avx2). After first 4 vector size comparison, code must check whether it already passed the given offset. This patch implement avx2 offset check condition for strncmp function, if both string compare same for first 4 vector size. (cherry picked from commit 75870237ff3bb363447b03f4b0af100227570910) Diff: --- sysdeps/x86_64/multiarch/strcmp-avx2.S | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/sysdeps/x86_64/multiarch/strcmp-avx2.S b/sysdeps/x86_64/multiarch/strcmp-avx2.S index 78fc116877..156c19496a 100644 --- a/sysdeps/x86_64/multiarch/strcmp-avx2.S +++ b/sysdeps/x86_64/multiarch/strcmp-avx2.S @@ -591,7 +591,14 @@ L(loop_cross_page_2_vec): movl $(PAGE_SIZE / (VEC_SIZE * 4) - 1), %esi testq %rdi, %rdi +# ifdef USE_AS_STRNCMP + /* At this point, if %rdi value is 0, it already tested + VEC_SIZE*4+%r10 byte starting from %rax. This label + checks whether strncmp maximum offset reached or not. */ + je L(string_nbyte_offset_check) +# else je L(back_to_loop) +# endif tzcntq %rdi, %rcx addq %r10, %rcx /* Adjust for number of bytes skipped. */ @@ -627,6 +634,14 @@ L(loop_cross_page_2_vec): VZEROUPPER ret +# ifdef USE_AS_STRNCMP +L(string_nbyte_offset_check): + leaq (VEC_SIZE * 4)(%r10), %r10 + cmpq %r10, %r11 + jbe L(zero) + jmp L(back_to_loop) +# endif + .p2align 4 L(cross_page_loop): /* Check one byte/dword at a time. */