From patchwork Mon Jul 11 22:38:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Noah Goldstein X-Patchwork-Id: 55930 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 2548D398AC3F for ; Mon, 11 Jul 2022 22:39:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2548D398AC3F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1657579147; bh=fEAJ+MSfZAI/szGQPML81hX5vZI8MIimC2jLbqpbe48=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=I1zLI2sS5AMgp+nINJxOEEFY+04/rzC7595YFM89UsIvzhXwQB5KiPqk6q5rthsyR JO5MiWCFQwahr8ma8cPLUdHrSfGmJchX4LdQVsC4vMTBJVMa0PaE6kA887Q5eVWHjV jjdhq+iaR2dnoQIDjCyfVkXmh7LWckjjZGX7smhU= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by sourceware.org (Postfix) with ESMTPS id EBDDA3858035 for ; Mon, 11 Jul 2022 22:38:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org EBDDA3858035 Received: by mail-pg1-x52a.google.com with SMTP id e132so5967896pgc.5 for ; Mon, 11 Jul 2022 15:38:45 -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:in-reply-to :references:mime-version:content-transfer-encoding; bh=fEAJ+MSfZAI/szGQPML81hX5vZI8MIimC2jLbqpbe48=; b=4jE6UpTKgg7qKY5gbN1+yisKQFARGmZPb4ejM2lsL6sgZnBM7h6Z8VY52MELY7tizP QOwoPRO22U+C+lRMN5o3sHodUyZAUjwAR3Awj2HWb1qvgC6FZW2nRaHwNUF87WilRQoW e1BGzHrlGa7mjP2IIEYJ1VlPlqsQ2k73Sx2HYTqx7Z6kPp9oPACQrdMgVW1RxVn/flcD aLzEqKY5hcY204mZk9XOTZDuXUne9AA/KXx1Nw2heuzGlUJgQBZnWt5tpgIN9w4fvR8L VvkImUqyZ7MFbdqx922xZY/3bxNRWUlYarlWCa0y9BGzbcVkLrOaVBnIZuwyyOTOVyt9 655g== X-Gm-Message-State: AJIora+thnODvySVAHnrQ/wF0JLhPih8VNVMwSch9Zi/uMFqpwIJCTU4 9zKt8gboZSPvDRFGz8x7qfSX3pPHdfU= X-Google-Smtp-Source: AGRyM1uIp3wjb53E8jO0I8HUi+g950zcW/VRVsYhrqp9B7gzXX+hW8n0+2+0RNDI52ykrLDNMq20ow== X-Received: by 2002:a65:5688:0:b0:3c2:1015:988e with SMTP id v8-20020a655688000000b003c21015988emr17799861pgs.280.1657579124886; Mon, 11 Jul 2022 15:38:44 -0700 (PDT) Received: from noah-tgl.. ([192.55.60.37]) by smtp.gmail.com with ESMTPSA id bi9-20020a170902bf0900b0015e9f45c1f4sm5199733plb.186.2022.07.11.15.38.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Jul 2022 15:38:44 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH v2] x86: Remove __mmask intrinsics in strstr-avx512.c Date: Mon, 11 Jul 2022 15:38:41 -0700 Message-Id: <20220711223841.2041611-1-goldstein.w.n@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220711220730.1968923-1-goldstein.w.n@gmail.com> References: <20220711220730.1968923-1-goldstein.w.n@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, 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" Using standard operators generates and the same code and __mmask instrinsics are not available before GCC7. Removed: _cvtmask64_u64 _kshiftri_mask64 _kand_mask64 Reviewed-by: Sunil K Pandey --- sysdeps/x86_64/multiarch/strstr-avx512.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/sysdeps/x86_64/multiarch/strstr-avx512.c b/sysdeps/x86_64/multiarch/strstr-avx512.c index 2ab9e96db8..e44c1a05dc 100644 --- a/sysdeps/x86_64/multiarch/strstr-avx512.c +++ b/sysdeps/x86_64/multiarch/strstr-avx512.c @@ -26,6 +26,10 @@ #define ZMM_SIZE_IN_BYTES 64 #define PAGESIZE 4096 +#define cvtmask64_u64(...) (uint64_t) (__VA_ARGS__) +#define kshiftri_mask64(x, y) ((x) >> (y)) +#define kand_mask64(x, y) ((x) & (y)) + /* 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 +137,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); + 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 +182,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) {