From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by sourceware.org (Postfix) with ESMTPS id F10ED3858D32 for ; Sun, 2 Oct 2022 21:11:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org F10ED3858D32 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-x62e.google.com with SMTP id z23so1863413ejw.12 for ; Sun, 02 Oct 2022 14:11:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date; bh=XZi2UFUHTe0bVBuUvu66h6OWvBuyUqtbPSfi5WrfuAc=; b=gZA61/nPkhuNngIHf011CuZ/Bgqz9rkBXiootrKPbGNEHS/1w+7PD53AknJY7FD51z DVZKhh0t5Rwx0UJkg7++9vHJqqt6lkVrPY+l2ZPKaLg32jyZ9z7eI0e2T8jYtSAHDViS G0rxbZFa2pyu8AJamRWpcMMRbcTn5amY7j5qnZa0+rhsXz5SlecC0QGCCx2TLxjYmoxD MxLl8GyJKfOLLCFLyaTtSmxUjgPDy9s3/3tjcmJEHS/IKgr8gJKcTpeeWhdxUh3UgSpM 5I+sYdRDWtnpWgX/ffXm/UaFcQOq9b065gUUKng5pyxe+sjGIIuxps1RA6WPwif7X3oY VWlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date; bh=XZi2UFUHTe0bVBuUvu66h6OWvBuyUqtbPSfi5WrfuAc=; b=H01I0ew9lqp9H17/ml5j5aKbS3CC7LrdS4PqGrY+m9D13uYayVsnJQYGRTAtGJvMpw I+/ve10YT9a2jbIRhmSRnDtajIFvsCXX7TfSraRE1LjlzLBQVyehJJAP8O3kV+AclI4Q lGRPnehyy5oviHruAH7cTx46MSFrnbZqLT91SlLTwXqBuva7C6JdbUoGTDORdFTzvfZP pskcwhTf5J0qwiNn0k6USiTPIi7puzI7jqEgo6q62xgBSs+l3qp0XozXlHPiEjvx8KZ7 Sz+8/No4NKMPon2j9we6ISR6QwJsh4Qynr/zV6gM4SGHlkj/YL9vLB2y6JORTlNIykXb YXzQ== X-Gm-Message-State: ACrzQf3iq4r3gvgAjJ7RB8dd+DyLoMOKbDpR1a/dhapEgbFo9/oyNe3M Swxbb6iNw0ys+vAlr7TVtYqOo652p0NHD5GmKPg= X-Google-Smtp-Source: AMsMyM7fVQgbi0TDokVzHxIVq1fdpBmumN1OU/KrdGkgO1ExwueQtgr+ZtzNHHs2Q/y1jvbkV6tyGdnIT5N2RRdFAh8= X-Received: by 2002:a17:906:cc4e:b0:77c:b7a:9de6 with SMTP id mm14-20020a170906cc4e00b0077c0b7a9de6mr12707324ejb.531.1664745082664; Sun, 02 Oct 2022 14:11:22 -0700 (PDT) MIME-Version: 1.0 References: <20221002123424.3079805-1-aurelien@aurel32.net> In-Reply-To: From: Noah Goldstein Date: Sun, 2 Oct 2022 17:11:11 -0400 Message-ID: Subject: Re: [PATCH v2 0/6] x86: Fix AVX2 string functions requiring BMI1, BMI2 or LZCNT (BZ #29611) To: Noah Goldstein , libc-alpha@sourceware.org, "H . J . Lu" , Sunil K Pandey Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Sun, Oct 2, 2022 at 2:09 PM Aurelien Jarno wrote: > > On 2022-10-02 09:21, Noah Goldstein wrote: > > On Sun, Oct 2, 2022 at 5:34 AM Aurelien Jarno wrote: > > > > > > Some early Intel Haswell CPU have AVX2 instructions, but do not have > > > BMI1 and BMI2 instructions. Some AVX2 string functions only check for > > > AVX2, but use BMI1, BMI2 or LZCNT instructions. This patchset tries to > > > fix that. > > > > > > While most fixes only change ifunc-impl-list.c, and thus only concerns > > > the testsuite, the strn(case)cmp is a real issue affecting early Intel > > > > str(case)cmp as well, correct? > > Oops, yes forgot to update the cover letter on that aspect. > > > > Haswell CPU, reported to affect Debian Sid and Fedora Rawhide. > > > > > > On the other hand, the check for LZCNT in memrchr is purely for > > > correctness, I am not aware of a CPU implementing AVX2 without LZCNT. > > > > > > This has been tested by remplacing all BMI1 and BMI2 instructions in the > > > source code by the "ud2" instruction and disabling the BMI1, BMI2 > > > feature detection, and running the testsuite. > > > > > > Resolves: BZ #29611 > > > > > > Change v1 -> v2: > > > - Better scan for BMI2 instructions (shlx and shrx) and BMI1 > > > instructions (blsmsk) instructions following the feedback from Noah > > > Goldstein > > > > > > Aurelien Jarno (6): > > > x86: include BMI1 and BMI2 in x86-64-v3 level > > > x86-64: Require BMI2 for AVX2 str*cmp and wcs(n)cmp implementations > > > x86-64: Require BMI2 for AVX2 (raw|w)memchr implementations > > > x86-64: Require LZCNT for AVX2 memrchr implementation > > > x86-64: Require BMI1/BMI2 for AVX2 strrchr and wcsrchr implementations > > > x86-64: Require BMI2 for AVX2 memrchr implementation > > > > > > sysdeps/x86/get-isa-level.h | 2 + > > > sysdeps/x86/isa-level.h | 2 + > > > sysdeps/x86_64/multiarch/ifunc-avx2.h | 2 + > > > sysdeps/x86_64/multiarch/ifunc-impl-list.c | 86 ++++++++++++++++----- > > > sysdeps/x86_64/multiarch/ifunc-strcasecmp.h | 1 + > > > sysdeps/x86_64/multiarch/strcmp.c | 4 +- > > > sysdeps/x86_64/multiarch/strncmp.c | 4 +- > > > 7 files changed, 76 insertions(+), 25 deletions(-) > > > > > > -- > > > 2.35.1 > > > > > > > -- > Aurelien Jarno GPG: 4096R/1DDD8C9B > aurelien@aurel32.net http://www.aurel32.net Patchset looks good. Do you have commit permissions? If not I can push them for you. Thanks for the bugfix! NB: the str*(case)cmp, wcs(n)cmp bug affects 2.36, 2.35, 2.34, 2.33.