From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-vk1-xa2c.google.com (mail-vk1-xa2c.google.com [IPv6:2607:f8b0:4864:20::a2c]) by sourceware.org (Postfix) with ESMTPS id ED6993857405; Thu, 28 Apr 2022 00:09:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org ED6993857405 Received: by mail-vk1-xa2c.google.com with SMTP id o132so1612753vko.11; Wed, 27 Apr 2022 17:09:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=6wFr4mtwa4n4gv9/l6vZ+zDVbHlRYtIixD4BUS39et4=; b=gig/b8q/Ol72u45FYX/MYOf1vQsl2opgvtOIXxkcuabUpn07P/5BDqJHLi8zEpLzR6 wHpfjuesX02lThnlu6FYxlsEXy4Iu6BxlWPdOMj4WuRaGgKOipgqzK3v3/7WLSuYTWDs XtoKQBOvzGaoeMaTiL0BUUpxadmgR8nOfb1lh/NOA/tvP0JJ8FzNVr4aYnPl37Rg8CNW oLKvO97d6o5AUPHM/yo9b/lk14iYCoBvIRApZtp+5fOxtZBmHtMZWGffY7IEY3tQC8h4 S+vRzFM0vqkvjCKbump6/3w2FNT4m10SF4vVLGGmkbQqZegN5yPYoaTPMTaoWbfyNmt0 DJjA== X-Gm-Message-State: AOAM5319tRiP4gptZk8fCCqkO0sWLeGAavZvw+EE094HL+L6EHS0UC6p sijn0gx1GnEkkQ66kn+4t9++UTcbH7myxXNZ4sw= X-Google-Smtp-Source: ABdhPJyJxldzZR5oZNu0YwOJMq6qpWKQZaeHgaQbKu4Uxt0eW6vgpanUZkKIesSz0Vmv+rNnSA6NKR6DnNsARDwZylA= X-Received: by 2002:a1f:2ccb:0:b0:345:8fa0:7689 with SMTP id s194-20020a1f2ccb000000b003458fa07689mr10340893vks.19.1651104542319; Wed, 27 Apr 2022 17:09:02 -0700 (PDT) MIME-Version: 1.0 References: <20210623235902.1614933-1-goldstein.w.n@gmail.com> <20210623235902.1614933-2-goldstein.w.n@gmail.com> In-Reply-To: From: Sunil Pandey Date: Wed, 27 Apr 2022 17:08:26 -0700 Message-ID: Subject: Re: [PATCH v1 2/2] x86: Remove unnecessary overflow check from wcsnlen-sse4_1.S To: "H.J. Lu" , libc-stable@sourceware.org Cc: Noah Goldstein , GNU C Library Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, GIT_PATCH_0, HK_RANDOM_ENVFROM, HK_RANDOM_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-stable@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-stable mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Apr 2022 00:09:04 -0000 On Wed, Jun 23, 2021 at 5:42 PM H.J. Lu via Libc-alpha wrote: > > On Wed, Jun 23, 2021 at 5:00 PM Noah Goldstein wrote: > > > > 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 > > --- > > Sorry I didn't notice this earlier before my last commit. As > > of submitting this patch > > > > a775a7a3eb1e85b54af0b4ee5ff4dcf66772a1fb > > > > Is HEAD of master to maybe rebase so commit history isnt messy? > > > > > > 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 > > -- > > 2.25.1 > > > > LGTM. > > Reviewed-by: H.J. Lu > > Thanks. > > -- > H.J. I would like to backport this patch to release branches. Any comments or objections? --Sunil