From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7852) id 24CB93858C27; Mon, 2 May 2022 21:30:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 24CB93858C27 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Sunil Pandey To: glibc-cvs@sourceware.org Subject: [glibc/release/2.33/master] x86: Remove unnecessary overflow check from wcsnlen-sse4_1.S X-Act-Checkin: glibc X-Git-Author: Noah Goldstein X-Git-Refname: refs/heads/release/2.33/master X-Git-Oldrev: de7fd57d7576d2522408ad74f1052a5d775ffeec X-Git-Newrev: 853f83686ae12f572eea0546ed3cd195113653b3 Message-Id: <20220502213009.24CB93858C27@sourceware.org> Date: Mon, 2 May 2022 21:30:09 +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: Mon, 02 May 2022 21:30:09 -0000 https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=853f83686ae12f572eea0546ed3cd195113653b3 commit 853f83686ae12f572eea0546ed3cd195113653b3 Author: Noah Goldstein Date: Wed Jun 23 19:19:34 2021 -0400 x86: Remove unnecessary overflow check from wcsnlen-sse4_1.S No bug. The way wcsnlen will check if near the end of maxlen is the following macro: mov %r11, %rsi; \ subq %rax, %rsi; \ andq $-64, %rax; \ testq $-64, %rsi; \ je L(strnlen_ret) Which words independently of s + maxlen overflowing. So the second overflow check is unnecissary for correctness and just extra overhead in the common no overflow case. test-strlen.c, test-wcslen.c, test-strnlen.c and test-wcsnlen.c are all passing Signed-off-by: Noah Goldstein Reviewed-by: H.J. Lu (cherry picked from commit 08cbcd4dbc686bb38ec3093aff2f919fbff5ec17) Diff: --- sysdeps/x86_64/multiarch/strlen-vec.S | 7 ------- 1 file changed, 7 deletions(-) diff --git a/sysdeps/x86_64/multiarch/strlen-vec.S b/sysdeps/x86_64/multiarch/strlen-vec.S index 439e486a43..b7657282bd 100644 --- a/sysdeps/x86_64/multiarch/strlen-vec.S +++ b/sysdeps/x86_64/multiarch/strlen-vec.S @@ -71,19 +71,12 @@ L(n_nonzero): suffice. */ mov %RSI_LP, %R10_LP sar $62, %R10_LP - test %R10_LP, %R10_LP jnz __wcslen_sse4_1 sal $2, %RSI_LP # endif - /* Initialize long lived registers. */ - add %RDI_LP, %RSI_LP -# ifdef AS_WCSLEN -/* Check for overflow again from s + maxlen * sizeof(wchar_t). */ - jbe __wcslen_sse4_1 -# endif mov %RSI_LP, %R10_LP and $-64, %R10_LP mov %RSI_LP, %R11_LP