| Message ID | 20260528081950.1417009-1-xiejiamei@hygon.cn (mailing list archive) |
|---|---|
| Headers |
Return-Path: <libc-alpha-bounces~patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9BDF24BAE7FC for <patchwork@sourceware.org>; Thu, 28 May 2026 08:21:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9BDF24BAE7FC X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mailgw1.hygon.cn (unknown [101.204.27.37]) by sourceware.org (Postfix) with ESMTP id 043134BA903A for <libc-alpha@sourceware.org>; Thu, 28 May 2026 08:20:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 043134BA903A Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=hygon.cn Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=hygon.cn ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 043134BA903A Authentication-Results: sourceware.org; arc=none smtp.remote-ip=101.204.27.37 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1779956406; cv=none; b=dpF2MO3j2yoD6mCViOTnMq0oQW3bFgCivLnREce5uJwUM1f6CR+vkKgHndteJN15lLo5GDIctyf8djAdBySjPZB0zSJXhPNDsF7bjB+qBiDZeJ7ly7Et4LrTcAex2LV0PPy+xQFnRl3Mal17omtwbHboskf68WbQhRpuZn6D0Tk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1779956406; c=relaxed/simple; bh=/E6PQpNrcrBluhnW0r+bJyy9NqPZU28U2iVR2fAc9pY=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=T/vm0MblCwuGe9cQucLrMzU2G+BBJXC4aY7LTMqICrsyrSMgkdDLGo/eqfra928CVNXctH/Cwb0ZrkLPQSNYz4f/7XedwNkUphu6mxLaO85mDPCYe1D4zKSvfV8eS1V8qoTrsQNoMN0JEq/jtiViDHDd1idnHhgr0hKNbmI47QU= ARC-Authentication-Results: i=1; sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 043134BA903A Received: from maildlp2.hygon.cn (unknown [127.0.0.1]) by mailgw1.hygon.cn (Postfix) with ESMTP id 4gQztr0zhPz5Tp0y for <libc-alpha@sourceware.org>; Thu, 28 May 2026 16:20:04 +0800 (CST) Received: from maildlp2.hygon.cn (unknown [172.23.18.61]) by mailgw1.hygon.cn (Postfix) with ESMTP id 4gQztq51vXz5Tp0y for <libc-alpha@sourceware.org>; Thu, 28 May 2026 16:20:03 +0800 (CST) Received: from cncheex04.Hygon.cn (unknown [172.23.18.114]) by maildlp2.hygon.cn (Postfix) with ESMTPS id 23A3730004DE for <libc-alpha@sourceware.org>; Thu, 28 May 2026 16:19:03 +0800 (CST) Received: from Mei.hygon.cn (172.19.22.176) by cncheex04.Hygon.cn (172.23.18.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.36; Thu, 28 May 2026 16:20:03 +0800 From: Jiamei Xie <xiejiamei@hygon.cn> To: <libc-alpha@sourceware.org> CC: <lijing@hygon.cn>, <xiejiamei@hygon.cn> Subject: [RFC PATCH v1 0/1] x86: Use TZCNT-based EVEX string variants on Hygon Date: Thu, 28 May 2026 08:19:49 +0000 Message-ID: <20260528081950.1417009-1-xiejiamei@hygon.cn> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.19.22.176] X-ClientProxiedBy: cncheex05.Hygon.cn (172.23.18.115) To cncheex04.Hygon.cn (172.23.18.114) X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE, SPF_PASS, TXREP shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list <libc-alpha.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/libc-alpha/> List-Post: <mailto:libc-alpha@sourceware.org> List-Help: <mailto:libc-alpha-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=subscribe> Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org |
| Series |
x86: Use TZCNT-based EVEX string variants on Hygon
|
|
Message
Jiamei Xie
May 28, 2026, 8:19 a.m. UTC
Hi, This RFC proposes using TZCNT instead of BSF to find the first set bit in selected EVEX string routines on Hygon processors. For non-zero input operands, TZCNT produces the same result as BSF. The modified paths only use TZCNT when the input mask is already known to be non-zero, so the change does not rely on TZCNT's zero-input semantics. Benchmarking shows that TZCNT is faster than BSF in several hot EVEX string implementations on Hygon processors. This RFC adds a new preferred feature bit, Prefer_TZCNT_for_stringop, sets it for Hygon processors, and uses it to select TZCNT-based EVEX variants for: strlen strcpy strchr strcmp strncmp memcmp The implementation keeps the existing EVEX assembly as the common source. The default code path continues to use BSF through FIND_FIRST_SET and FIND_FIRST_SETQ macros, while small TZCNT wrapper files override those macros and include the original implementation. This keeps the change localized and avoids duplicating the full assembly sources. Dispatch for non-Hygon processors is unchanged. Benchmark results relative to the existing EVEX variants: Function Hygon model 7 Hygon model 8 __strlen_evex +12.32% +11.89% __strcpy_evex +5.83% +4.25% __strchr_evex +9.21% +9.76% __strcmp_evex +6.28% +7.79% __memcmp_evex +10.30% +10.99% __strncmp_evex +4.26% +4.92% Positive numbers mean the TZCNT variant is faster than the existing EVEX variant. Feedback is welcome. Thanks Jiamei Xie (1): x86: Add TZCNT variants for selected Hygon string functions sysdeps/x86/cpu-features.c | 5 +++ ...cpu-features-preferred_feature_index_1.def | 1 + sysdeps/x86_64/multiarch/Makefile | 6 ++++ sysdeps/x86_64/multiarch/ifunc-avx2.h | 8 +++++ sysdeps/x86_64/multiarch/ifunc-impl-list.c | 36 +++++++++++++++++++ sysdeps/x86_64/multiarch/ifunc-memcmp.h | 13 ++++++- sysdeps/x86_64/multiarch/ifunc-strcpy.h | 13 ++++++- .../multiarch/memcmp-evex-movbe-tzcnt.S | 8 +++++ sysdeps/x86_64/multiarch/memcmp-evex-movbe.S | 23 ++++-------- sysdeps/x86_64/multiarch/memcmp.c | 1 + sysdeps/x86_64/multiarch/strchr-evex-tzcnt.S | 8 +++++ sysdeps/x86_64/multiarch/strchr-evex.S | 16 ++++----- sysdeps/x86_64/multiarch/strchr.c | 5 +++ sysdeps/x86_64/multiarch/strcmp-evex-tzcnt.S | 5 +++ sysdeps/x86_64/multiarch/strcmp-evex.S | 34 +++++++++--------- sysdeps/x86_64/multiarch/strcmp.c | 9 ++++- sysdeps/x86_64/multiarch/strcpy-evex-tzcnt.S | 7 ++++ sysdeps/x86_64/multiarch/strcpy-evex.S | 18 +++++----- sysdeps/x86_64/multiarch/strcpy.c | 1 + sysdeps/x86_64/multiarch/strlen-evex-base.S | 14 ++++---- sysdeps/x86_64/multiarch/strlen-evex-tzcnt.S | 10 ++++++ sysdeps/x86_64/multiarch/strlen.c | 1 + sysdeps/x86_64/multiarch/strncmp-evex-tzcnt.S | 6 ++++ sysdeps/x86_64/multiarch/strncmp.c | 9 ++++- sysdeps/x86_64/sysdep.h | 8 +++++ 25 files changed, 205 insertions(+), 60 deletions(-) create mode 100644 sysdeps/x86_64/multiarch/memcmp-evex-movbe-tzcnt.S create mode 100644 sysdeps/x86_64/multiarch/strchr-evex-tzcnt.S create mode 100644 sysdeps/x86_64/multiarch/strcmp-evex-tzcnt.S create mode 100644 sysdeps/x86_64/multiarch/strcpy-evex-tzcnt.S create mode 100644 sysdeps/x86_64/multiarch/strlen-evex-tzcnt.S create mode 100644 sysdeps/x86_64/multiarch/strncmp-evex-tzcnt.S