From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by sourceware.org (Postfix) with ESMTPS id 14C6D3858D38 for ; Mon, 3 Oct 2022 17:51:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 14C6D3858D38 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-x629.google.com with SMTP id z23so7070163ejw.12 for ; Mon, 03 Oct 2022 10:51:53 -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=ssax7Npf9NvYN2G9D+YRlDoYPRjGGz6MLIEBxgudO5M=; b=Jzu03s5XXWp9A1oGLmh1T+bVDM2lseSet0UGnTEoFfInoCouQQc84v+ztzwPTovwCA WyFj3qfOFKkZMvhiQRSSx5pLL4Wm2O3aE38oPniL/pqkcwDWQVJwtJo4Mk/ah8ufkWa2 xWkvvyMoM9IIXPqABtXjnOoNlJJSGdgntp0QjrXXMUFF6bzblepeCyUipO72EKHKObGb stXkniw5STr+pQk4xU71Hjwvv1rwtDqnGmnMKCxHjtHSp5IjIKwkR1tPSUrn9/Uiy8/x w0YwYqH3CUoy9J7qUUIDrB86Hdaw9agXCRzMm+rOlkvTq9HORDgw7lFVtiYDXqA1ICTd +58w== 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=ssax7Npf9NvYN2G9D+YRlDoYPRjGGz6MLIEBxgudO5M=; b=wEi1w121RME0WI+XjBKlTg+ua1scZ21dhX6R6yFm7oodzsYErKTrlBWWVLQdfBZeYh 7gR3EvBONbiWCX8CiVQ8cQ0D2SOMEXF7cPwibJ8yNi3ktz0LRFnoUIFh+b3D0HCiAzbG ncq3SU8FhKvmYSxnp2nZt51Oldp5qQmIRbPWLaiYQn+tE3kW3WnYYqmqnRZ/E3yut5mO 2DNzoxzChHbmntNipP2qs3vBTtLP723ESLlDnSkUrEA3UArRdDzBTpmAis59k7g6vBYU VIHIzYSXWMnKnIBwU+zGDJro9C+h9JJS6uyBJUszC+wfVleJx3Zg160GAL4zwTgOS9xP OpRA== X-Gm-Message-State: ACrzQf0jLgwZmhkacbGH6lEvVGov7U+4QHWNruayCaVjwtobl4y5v/HP 4O+toiMiU6SG4u2Q+gpKxZyS2dX7yz+MMovSFHmGPAXR X-Google-Smtp-Source: AMsMyM4mOGS5bOmhD+syTCfEeX1KuSCl+oIziW16f4SKBn3rf1pMglChSJniBvdYzDufz2qkzjQsALFH0zhHuchSQoY= X-Received: by 2002:a17:907:6ea1:b0:783:cc69:342 with SMTP id sh33-20020a1709076ea100b00783cc690342mr15429526ejc.97.1664819511738; Mon, 03 Oct 2022 10:51:51 -0700 (PDT) MIME-Version: 1.0 References: <20221002123424.3079805-1-aurelien@aurel32.net> In-Reply-To: From: Noah Goldstein Date: Mon, 3 Oct 2022 10:51:40 -0700 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.6 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 Mon, Oct 3, 2022 at 10:36 AM Aurelien Jarno wrote: > > On 2022-10-02 17:11, Noah Goldstein via Libc-alpha wrote: > > 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. > > Yes, I can commit them, though I'll wait for v3 to be reviewed. > > > Thanks for the bugfix! > > > > NB: > > the str*(case)cmp, wcs(n)cmp bug affects 2.36, 2.35, 2.34, 2.33. > > Yep, I have already prepared a backport of the whole patchset to those > branches. > If thats the case you may not need V3 because AFAIK thats the only reason to split the strcmp patches up. Sunil can you comment? > -- > Aurelien Jarno GPG: 4096R/1DDD8C9B > aurelien@aurel32.net http://www.aurel32.net