From patchwork Mon Jul 11 22:07:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Noah Goldstein X-Patchwork-Id: 55929 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A5668398240E for ; Mon, 11 Jul 2022 22:08:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A5668398240E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1657577299; bh=rCYOtxhcsiPXFG/l+pkooGjIdG6jaHYo4X15hnYLfVI=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=sjwb2faXpOuUSnK71WvvLAmknBu0SWBljVTjZkSJC5ZsUx6bJebn371LvBkMn8o4o LyehY055FhKSYKArsM+Z8waAUX2aJttOKA0AflYux6i3jtSsB8F96bB4UpHdMwq6v+ lN4i+CAv9nRhE9eE+S4ez9rIfPL5tLFGCNlqLvHU= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by sourceware.org (Postfix) with ESMTPS id 1796A3852747 for ; Mon, 11 Jul 2022 22:07:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1796A3852747 Received: by mail-pj1-x102f.google.com with SMTP id o5-20020a17090a3d4500b001ef76490983so6186760pjf.2 for ; Mon, 11 Jul 2022 15:07:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=rCYOtxhcsiPXFG/l+pkooGjIdG6jaHYo4X15hnYLfVI=; b=SdS8X3pz/2Jt5nj6mg3EsNobMtj5DMlTmfRY8nSddWt5/zAVEdJuZWwGJPDambO9IC AKudeUHGMXkZ9y+a7z/NxYl2uvdOM4IWxV8aOJlEguSBaVV516W1/rKiVvpxTI5rxHu4 wvik2rs7/tyokqfuTsYAjUfbOb1qYVBCRIdquJCLnHcY2m6glNYbWzxSdShbWEUnSYT0 sFygl+W7VlZumbfVDs5fuQDitmxf9QLsCAlz05FNmn9rbhoafskVfF/TkqcehYh+BMj7 vbGRzMoTUiNYGeHwLyytOZOCqx5yDaNJW+RrXulvLGcno3TLu3PHGYS7x1ifVQuMBfzJ GE+Q== X-Gm-Message-State: AJIora8GqzzncdyZif1hfNdrVBoXmXCciHJ/6sqAHaAD68WFR295vI1X P1cOcGVRK3jF5ic7yz5FToI5xHvY3b8= X-Google-Smtp-Source: AGRyM1tFAnqz58v2LXx+Y3RbL6DSqg27BdbG2CwaNZ8+qUX3qhBMGa8WD9/gFPWHNryB5y5GmEH/3A== X-Received: by 2002:a17:90a:fa01:b0:1ef:6e6a:4ff0 with SMTP id cm1-20020a17090afa0100b001ef6e6a4ff0mr550593pjb.35.1657577253949; Mon, 11 Jul 2022 15:07:33 -0700 (PDT) Received: from noah-tgl.. ([192.55.60.37]) by smtp.gmail.com with ESMTPSA id c83-20020a624e56000000b0050dc76281f8sm5172766pfb.210.2022.07.11.15.07.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Jul 2022 15:07:33 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH v1] x86: Use regular casting instead of _cvtmask64_u64 in strstr-avx512 Date: Mon, 11 Jul 2022 15:07:30 -0700 Message-Id: <20220711220730.1968923-1-goldstein.w.n@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Noah Goldstein via Libc-alpha From: Noah Goldstein Reply-To: Noah Goldstein Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" _cvtmask64_u64 is not available before GCC7. --- sysdeps/x86_64/multiarch/strstr-avx512.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/sysdeps/x86_64/multiarch/strstr-avx512.c b/sysdeps/x86_64/multiarch/strstr-avx512.c index 2ab9e96db8..e41b44abe1 100644 --- a/sysdeps/x86_64/multiarch/strstr-avx512.c +++ b/sysdeps/x86_64/multiarch/strstr-avx512.c @@ -26,6 +26,8 @@ #define ZMM_SIZE_IN_BYTES 64 #define PAGESIZE 4096 +#define cvtmask64_u64(...) (uint64_t) (__VA_ARGS__) + /* Returns the index of the first edge within the needle, returns 0 if no edge is found. Example: 'ab' is the first edge in 'aaaaaaaaaabaarddg' @@ -133,15 +135,15 @@ __strstr_avx512 (const char *haystack, const char *ned) __m512i hay0 = _mm512_maskz_loadu_epi8 (loadmask, haystack + hay_index); /* Search for NULL and compare only till null char */ uint64_t nullmask - = _cvtmask64_u64 (_mm512_mask_testn_epi8_mask (loadmask, hay0, hay0)); + = cvtmask64_u64 (_mm512_mask_testn_epi8_mask (loadmask, hay0, hay0)); uint64_t cmpmask = nullmask ^ (nullmask - ONE_64BIT); - cmpmask = cmpmask & _cvtmask64_u64 (loadmask); + cmpmask = cmpmask & cvtmask64_u64 (loadmask); /* Search for the 2 charaters of needle */ __mmask64 k0 = _mm512_cmpeq_epi8_mask (hay0, ned0); __mmask64 k1 = _mm512_cmpeq_epi8_mask (hay0, ned1); k1 = _kshiftri_mask64 (k1, 1); /* k2 masks tell us if both chars from needle match */ - uint64_t k2 = _cvtmask64_u64 (_kand_mask64 (k0, k1)) & cmpmask; + uint64_t k2 = cvtmask64_u64 (_kand_mask64 (k0, k1)) & cmpmask; /* For every match, search for the entire needle for a full match */ while (k2) { @@ -178,13 +180,13 @@ __strstr_avx512 (const char *haystack, const char *ned) hay0 = _mm512_loadu_si512 (haystack + hay_index); hay1 = _mm512_load_si512 (haystack + hay_index + 1); // Always 64 byte aligned - nullmask = _cvtmask64_u64 (_mm512_testn_epi8_mask (hay1, hay1)); + nullmask = cvtmask64_u64 (_mm512_testn_epi8_mask (hay1, hay1)); /* Compare only till null char */ cmpmask = nullmask ^ (nullmask - ONE_64BIT); k0 = _mm512_cmpeq_epi8_mask (hay0, ned0); k1 = _mm512_cmpeq_epi8_mask (hay1, ned1); /* k2 masks tell us if both chars from needle match */ - k2 = _cvtmask64_u64 (_kand_mask64 (k0, k1)) & cmpmask; + k2 = cvtmask64_u64 (_kand_mask64 (k0, k1)) & cmpmask; /* For every match, compare full strings for potential match */ while (k2) {