From patchwork Thu Jul 30 16:08:13 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wilco Dijkstra X-Patchwork-Id: 140274 Return-Path: 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 EDB824BBCDC4 for ; Thu, 30 Jul 2026 16:10:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EDB824BBCDC4 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=BRNuALmC; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=BRNuALmC X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from MRWPR03CU001.outbound.protection.outlook.com (mail-francesouthazon11011069.outbound.protection.outlook.com [40.107.130.69]) by sourceware.org (Postfix) with ESMTPS id C215A4BB3BB7 for ; Thu, 30 Jul 2026 16:09:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C215A4BB3BB7 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C215A4BB3BB7 Authentication-Results: sourceware.org; arc=pass smtp.remote-ip=40.107.130.69 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1785427781; cv=pass; b=nB2GLHHdG+LUNbYkXkP2MjGt1PWuA2E5o4SaTcsjNJN/Gn6eDoAm0emFkR8+39J/tckQPSyLlGrOuCJgj16WHQp020jDBilhz5Fr5GKblMe7KHpWAWZAjNUlmUpn8a046rwfB044uIFIqW6rjSaMazLOJU9xOIUZNHeNSaTfEHM= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1785427781; c=relaxed/simple; bh=DN7Q2FVmG6BhUvLinUfwHWIcA432FJ/m7f252r9Uwcg=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-ID: MIME-Version; b=v0H+VP/jj31BCErg7eGwZLdcbZTOwG9PDiQNlr7QufE6n7xeBgI1VEFAXQOf30EeRuyS7fKTKs6zUroK4DBsfSyBZQw2N4j5C3jwN3uQbDP6Iztn/Sw0pqJ7/+b+bcw1v2d/1it8UF9/ZlF2c7HrDOAvtBvL00vjsLZ9Uaaq4fc= ARC-Authentication-Results: i=3; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=BRNuALmC; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=BRNuALmC DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C215A4BB3BB7 ARC-Seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=ohsmmEI+oKSnxnEbVwx8WICcR+8XuIBglN7+bGo2ymIJ8OYtzVfZisK0vHnKh+XHKQGKmME5hbGMxEY2fqcmK6vWJ0slyeX1Z3eIHL6LRXZjRve8olsGQoWCc8BFhcCiwN9LgYg8xOtkVAGs2bfgM5OgJKTF2b4AXEtJ3MWrMbULeova7Jf9O4eu6JKCFFGSr5bLgIg6OoCVIML6pDe9lOh14WU270cmFXuB8HCtj+R7a/0gDnFscjEz6I4UzWaXxEIhIzqy51A32r3ldoMBmUyp3Tr+d2Lhqq8ol1js1WjHwnHnxLmRn1fgRv8ma54Tv9SocuQBD/xABrgq2msTKg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=gdKppF/RUFngPPoQQGcoeP8VpjOg7xxpPaeG+rwbZqU=; b=QYmZbj+V/mkBr3ulR4Vaozal0XhOtP72Ci0JzX8tC+WBhh49r2PEpKDGoW5fV4g/ujmC3pf8dffVKtMY6ysMc2foqOwpfhUyUZskLMsfYBhiIdjdWgF4MoWMVmqcC9F9rnTskefBHFtUnSNsVCdIlcasOd6OCpFKVsILuMI40m9wz+Gw78/aOvQtbYDU/KrVhqVOQFfmZPlFLXPwmxs0K5B7eMbG3Zybql4ZoKjvqNyjn/J9+jwfv/vbA66bCD/9lhx3gmgN84t9Fde+BeVkOIz/KohVK4c/goq2iE1HB1EOcs9OLlVaPrrt4N2GXjYa8d5KVHYBCkjyB19w2wjd7g== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 4.158.2.129) smtp.rcpttodomain=sourceware.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=arm.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com]) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arm.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gdKppF/RUFngPPoQQGcoeP8VpjOg7xxpPaeG+rwbZqU=; b=BRNuALmCwNED9DrYRos9y/PA8KmY/Xs5LHs3bN/hKZ2d8h/4iT0gmG3dV2bfgDSpgSLUJnXHYpt82rIBOVD8lqO1sGESHSWE2snC7wLq5NRt6L7wQAc7bYkwIQvx31ijMdKx9TUSy99+CU1Vc7/xrX91tOM0gOpyum4EkaPqZhw= Received: from DU7P250CA0018.EURP250.PROD.OUTLOOK.COM (2603:10a6:10:54f::31) by AS8PR08MB9624.eurprd08.prod.outlook.com (2603:10a6:20b:617::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.15; Thu, 30 Jul 2026 16:09:20 +0000 Received: from DU2PEPF00028D11.eurprd03.prod.outlook.com (2603:10a6:10:54f:cafe::17) by DU7P250CA0018.outlook.office365.com (2603:10a6:10:54f::31) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.270.14 via Frontend Transport; Thu, 30 Jul 2026 16:09:20 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 4.158.2.129) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=arm.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 4.158.2.129 as permitted sender) receiver=protection.outlook.com; client-ip=4.158.2.129; helo=outbound-uk1.az.dlp.m.darktrace.com; pr=C Received: from outbound-uk1.az.dlp.m.darktrace.com (4.158.2.129) by DU2PEPF00028D11.mail.protection.outlook.com (10.167.242.25) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.292.8 via Frontend Transport; Thu, 30 Jul 2026 16:09:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=F+V7y4pjjsqe8fUSRHa8nvJGfQua8UleRQMBEa2vQtu4/xXMBtyFCtpyLkb3Nhoby8sTSubB156HwKi0qzjbm2Rvu3tOOTec3A1e6s3h/qv6sJgSRU1sVtIKuFIRWQTVVYxBYx3qZTyQ/1ZSj0Mgu2pN+Br2B0mTOGwhbgTdFTd+av2lBj0iVSKv0V7VXWHmhhXQBT1Rj0W9KW2oTzpyknbxphDsPVXcW55imf2tiSnifeLjuutqme7ulpegxDiFKhcDUKAY9bvODrruohxfXUo3YX7J6SJibngGvsmHl3qdd/EWh3tZ4DxFC35KpUwBOC4G5L7GfUMU1LkF29AJZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=gdKppF/RUFngPPoQQGcoeP8VpjOg7xxpPaeG+rwbZqU=; b=k3pSIgPDzU7XU8fhu2mWu+IpiIv0nE4Y6pbr3M7COo4E370Oi1VOPcaWewghUtA5/OtuZUdrduSoWIBxVz/cpYup4JvnRnyfjKtmOIv81jsoHnJwpJL5nHcGGc9A60DfgiAWiidid/sj1neDgfxg6HlFeKaQDJrGHbMPmqShZUW/3eAldkFMeQr3zMKcpya2tcgJmojff3Uuiu09qtuoLMLx9Du/FeW5Mgy7eWOlGrnxIAUYUr5P3b7C4clbWD8lgXJzxb2Nd/QIhegOAxwCDRHRI3149UsiMEV9Hw/XvsY5+E6VOb51sp9A57ICx9WITN56oRfBanmHS+R294pM7g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arm.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gdKppF/RUFngPPoQQGcoeP8VpjOg7xxpPaeG+rwbZqU=; b=BRNuALmCwNED9DrYRos9y/PA8KmY/Xs5LHs3bN/hKZ2d8h/4iT0gmG3dV2bfgDSpgSLUJnXHYpt82rIBOVD8lqO1sGESHSWE2snC7wLq5NRt6L7wQAc7bYkwIQvx31ijMdKx9TUSy99+CU1Vc7/xrX91tOM0gOpyum4EkaPqZhw= Received: from PAWPR08MB8982.eurprd08.prod.outlook.com (2603:10a6:102:33f::20) by GV1PR08MB8107.eurprd08.prod.outlook.com (2603:10a6:150:94::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.14; Thu, 30 Jul 2026 16:08:13 +0000 Received: from PAWPR08MB8982.eurprd08.prod.outlook.com ([fe80::5821:707a:c30b:dd9a]) by PAWPR08MB8982.eurprd08.prod.outlook.com ([fe80::5821:707a:c30b:dd9a%5]) with mapi id 15.21.0270.009; Thu, 30 Jul 2026 16:08:13 +0000 From: Wilco Dijkstra To: GNU C Library Subject: [PATCH] AArch64: Add SVE2 strchr Thread-Topic: [PATCH] AArch64: Add SVE2 strchr Thread-Index: AQHdID1TQuqzyvQe1UW7zcWtl49G2w== Date: Thu, 30 Jul 2026 16:08:13 +0000 Message-ID: Accept-Language: en-GB, en-US Content-Language: en-GB X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; x-ms-traffictypediagnostic: PAWPR08MB8982:EE_|GV1PR08MB8107:EE_|DU2PEPF00028D11:EE_|AS8PR08MB9624:EE_ X-MS-Office365-Filtering-Correlation-Id: 23569fe6-6cfa-48aa-7ed2-08deee54ea4a x-checkrecipientrouted: true nodisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; ARA:13230040|376014|23010399003|1800799024|366016|38070700021|13003099007|10067099003|11063799006|56012099006|5023799004|18002099003; X-Microsoft-Antispam-Message-Info-Original: qpbg8mAuCYHxypwPq3IFnLHFnY6ZwOqkI1ZylLT52z8vmI8/can3B0W+3LbSZy1pmBXsacQ9/3p/qxkiYia+nBoZ5Y9KQ7Vc8cpfBO5blW8x9wS3MazeDBHZmL0MGA0qTcqJlmF7djpmAdsA1qh6S37lpaexbx3DC0AnF5rbJe/+8nTo2hXMVO1l30hd2JZG9LKI8g2fG3PvtKiuYP+dZaihD6bwcD2fdoC0Qx9/+effOjinXP2He2dbUZ502MY0+nlDKtlS7arCzeAasOa95tUln0ujie6T2pbNMwPh0C0viGXp/jb4lBPBC4xnL6fi+Qa1+q1p0CstIF2tex9isvOH63M77jSSpmGfosMXU5caicHF94QO3w+bmzCCAPFHZds9muZ32BIGKf5a/+mORTbswjZUmPiR0HPq+9wYGLgq8bNvAy/oqnT7sriu756DP6uSs6MsJ1zib5sGedbTaQh9lpld5ZlJTiXZgjIQZnon5tj1IUzqo3ZyZ9xut+KtWqZduCrO/Ts/U/9SdMfRHnPUhPFv4WONonIEYojtR2WosB5nrJVJHhIOFox2aASZl1E8JEC6Sop5aZzW0RnBAeh1BvghRWgoG1wol30SfqGwDMfS/7bf3NtcW0+DTqSdH7yFxlNzOPiT9QCePFx7y0bpAe0QjWUI7GvvrF3kLYdb998oR49l47hRdgfJ9sMdcNk573yJ2Hsce317Uw/Ad38j5KCil8Yv7mLCeO30oZE= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAWPR08MB8982.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(23010399003)(1800799024)(366016)(38070700021)(13003099007)(10067099003)(11063799006)(56012099006)(5023799004)(18002099003); DIR:OUT; SFP:1101; MIME-Version: 1.0 X-Exchange-RoutingPolicyChecked: Tz+JafMB8QD5YbcWDGPCMZr7svCfuZggEn2mkWPv3R9mQCtj5+xQf0A60zyJbcrCUI1ZPxnVJEFJneL2PH1VhNEr816piqbQdS1Ic52wVGGrLiKFkHtLDCWeOWRX+pWVeUdPSNAHJ+dydPfg0zk0qUMAicCFH7kfHWAKUzZHsCRj/TSGIsTDs5mZuWBURZ9sV4fGVxc0wkpIAbOANYPwegUry+p5pIY2ily4nX3R3147nxH09hfbhkSQ3C6dRrJtOkgU8ULvPJSw55+bqHukQp+5LZC101zsYlYO6V/Yj6gPyZK7aHuUxx008Jumi6PReEeD/WEFSbM2lUU59gfMEQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR08MB8107 X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DU2PEPF00028D11.eurprd03.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 6b83df8c-f83e-460a-70d8-08deee54c20e X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700016|376014|23010399003|82310400026|14060799003|1800799024|35042699022|13003099007|56012099006|5023799004|11063799006|10067099003|18002099003; X-Microsoft-Antispam-Message-Info: Dq299rag9cBOYAXS4a/u3SC6IYYRHJc5zGMC5McZ9h8xgyKu03pWZakdtNQ83n26NNh2aZltnCuYdh3fz8aBVNLAdO7K8ayE6Z1UY4umBbHvYwJjvjnrMFUR/kH+Yc+G5CBZVsLcxrAyCCx4NLFbD/si0HmyveKGupa8ueX2y1vB5HgzD1CDjE7eEnwbsskQD9bLTjqI35saTjrV1yh40fmZ0uZciVf5vn2L7g7oaD0tUPkR5ll1Lx7fwRYRPCipRK+JXOfPqpOx+W3OPI3P5ItGVFKjmOMf2MzChkFy/mpcCBCB/xGjS08/SD7cgFyhMeYj5a6Rt4JSWotf8e+1jY+8+ENJLS234UoCFIvuUpWQWpNR7adP3Gw2DH8WOntQGkIQd9mqQdR1ByNW5QmR+S7xaXCLcV9ASvxUT3KyAW62WjCpLcIYZfnUZZQZ6lVx8Ja3QPTHAhzsxHkRrTLLW669tpxV3sltwElkpxUvmQJkhn+JXY3TOErZrhsUORhC2TrEir7DtUNnp3ZirJLtCNmNVr0IuTsJrb3T36U8qXheGMNOpLIh0NONojF9i49Exvz+2QU6/Pbq30a3KcpONIM/V85bN8Xz8jr0VSQej0Zn0Q6bPWIkgWAmYUFPdYZRWi9VgBYE2htRvnfkGdtQcivrpfp0jL2Da62wwBMzAEAuKI83CsAruHzyhzTIAb+lYps3p1XISP7mYO/I1eo6+A== X-Forefront-Antispam-Report: CIP:4.158.2.129; CTRY:GB; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:outbound-uk1.az.dlp.m.darktrace.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(36860700016)(376014)(23010399003)(82310400026)(14060799003)(1800799024)(35042699022)(13003099007)(56012099006)(5023799004)(11063799006)(10067099003)(18002099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1wwEz2WkSIvRgnJZO3N3Gb8d2ReIYT8/alt8RbFkDhL6ESbs3sJfvFSQpiPF7WqLqWNkeN/rbsGID2Qi1BE36Q3e8Dp5+Km1zrmwABf+qUK6Pu1fzMpGGcNWkzBFAWpucJm2kXaZMEG6g5f+hRaHUBIe+qayYKXpA3GWBhGdL4R+suKoY2PLrtSMuz+QBu7cnLobqESrf5Ir65JZKS0bdtPvpEKpnOzMNCOIXTS6HzgQtbUnjFtGA4T7VTu0Hxc+HwHdrOIOHCk3KKHhiudTAAM4Tff3pPBAzGTiiO9fAWOR6R/PaXjlAni4k6Tm98LIX9J2C5fiiYtU/Lo3hYVgIy285VnWBMOqGnI04+lZHbcwDSiJC2F66OqRpdDI87Qr+If8WqZKqbZl4YdxekaPVPMCrrx7EjgTmuAt4lIotkcsRbjFs6LjJLxe1b6HxPWl X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jul 2026 16:09:20.8175 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 23569fe6-6cfa-48aa-7ed2-08deee54ea4a X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[4.158.2.129]; Helo=[outbound-uk1.az.dlp.m.darktrace.com] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D11.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB9624 X-Spam-Status: No, score=-9.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FORGED_SPF_HELO, GIT_PATCH_0, KAM_LOTSOFHASH, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org Add an SVE2 strchr implementation and ifunc support. Use MATCH to check for both the input char and NUL. Performance of bench-strchr improves ~28% on Neoverse V2. diff --git a/sysdeps/aarch64/multiarch/Makefile b/sysdeps/aarch64/multiarch/Makefile index 38952655b1c14ac34a7bfdace01291e2802bd746..9f202512f1e32ddc0177d030bf295d3b7e202c1c 100644 --- a/sysdeps/aarch64/multiarch/Makefile +++ b/sysdeps/aarch64/multiarch/Makefile @@ -16,6 +16,8 @@ sysdep_routines += \ memset_oryon1 \ memset_sve_zva64 \ memset_zva64 \ + strchr_generic \ + strchr_sve2 \ strlen_asimd \ strlen_generic \ # sysdep_routines diff --git a/sysdeps/aarch64/multiarch/dl-symbol-redir-ifunc.h b/sysdeps/aarch64/multiarch/dl-symbol-redir-ifunc.h index 0910e321d24d84db951cf498c3e883c2cfdd01f5..50b2581455c94dc2bd38f8e5ba9a357d1b79e89f 100644 --- a/sysdeps/aarch64/multiarch/dl-symbol-redir-ifunc.h +++ b/sysdeps/aarch64/multiarch/dl-symbol-redir-ifunc.h @@ -22,6 +22,7 @@ asm ("memset = __memset_generic"); asm ("strlen = __strlen_generic"); #ifndef SHARED +asm ("strchr = __strchr_generic"); asm ("memcpy = __memcpy_generic"); asm ("memmove = __memmove_generic"); asm ("memcmp = __memcmp_generic"); diff --git a/sysdeps/aarch64/multiarch/ifunc-impl-list.c b/sysdeps/aarch64/multiarch/ifunc-impl-list.c index d43f6b58ee075c815b93ab2f42735e7e9f315d32..a0c93147c532d935d562a66ac67ebaa5326dd3bd 100644 --- a/sysdeps/aarch64/multiarch/ifunc-impl-list.c +++ b/sysdeps/aarch64/multiarch/ifunc-impl-list.c @@ -33,7 +33,6 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, INIT_ARCH (); - /* Support sysdeps/aarch64/multiarch/memcmp.c, memcpy.c, memmove.c and memset.c. */ IFUNC_IMPL (i, name, memcmp, IFUNC_IMPL_ADD (array, i, memcmp, sve, __memcmp_kunpeng950) IFUNC_IMPL_ADD (array, i, memcmp, 1, __memcmp_generic)) @@ -61,6 +60,8 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, IFUNC_IMPL (i, name, strlen, IFUNC_IMPL_ADD (array, i, strlen, !mte, __strlen_asimd) IFUNC_IMPL_ADD (array, i, strlen, 1, __strlen_generic)) - + IFUNC_IMPL (i, name, strchr, + IFUNC_IMPL_ADD (array, i, strchr, sve2 && !mte, __strchr_sve2) + IFUNC_IMPL_ADD (array, i, strchr, 1, __strchr_generic)) return 0; } diff --git a/sysdeps/aarch64/multiarch/strchr.c b/sysdeps/aarch64/multiarch/strchr.c new file mode 100644 index 0000000000000000000000000000000000000000..12f4e10bbe034ab462a4e578c69fd1d9b4afd9ed --- /dev/null +++ b/sysdeps/aarch64/multiarch/strchr.c @@ -0,0 +1,38 @@ +/* Multiple versions of strchr. AArch64 version. + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* Define multiple versions only for the definition in libc. */ + +#if IS_IN (libc) +/* Redefine strchr so that the compiler won't complain about the type + mismatch with the IFUNC selector in strong_alias, below. */ +# undef strchr +# define strchr __redirect_strchr +# include +# include + +extern __typeof (__redirect_strchr) __libc_strchr; + +extern __typeof (__redirect_strchr) __strchr_generic attribute_hidden; +extern __typeof (__redirect_strchr) __strchr_sve2 attribute_hidden; + +libc_ifunc (__libc_strchr, (sve2 && !mte ? __strchr_sve2 : __strchr_generic)); + +# undef strchr +strong_alias (__libc_strchr, strchr); +#endif diff --git a/sysdeps/aarch64/multiarch/strchr_generic.S b/sysdeps/aarch64/multiarch/strchr_generic.S new file mode 100644 index 0000000000000000000000000000000000000000..1fad64f9d98c5ec77346e1efa0d2bc6787c94420 --- /dev/null +++ b/sysdeps/aarch64/multiarch/strchr_generic.S @@ -0,0 +1,35 @@ +/* A Generic Optimized strchr implementation for AArch64. + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +#if IS_IN (libc) + +# define STRCHR __strchr_generic + +/* Do not hide the generic version of strchr, we use it internally. */ +# undef libc_hidden_builtin_def +# define libc_hidden_builtin_def(name) + +# ifdef SHARED +/* It doesn't make sense to send libc-internal strchr calls through a PLT. */ + .globl __GI_strchr; __GI_strchr = __strchr_generic +# endif +#endif + +#include "../strchr.S" diff --git a/sysdeps/aarch64/multiarch/strchr_sve2.S b/sysdeps/aarch64/multiarch/strchr_sve2.S new file mode 100644 index 0000000000000000000000000000000000000000..4f24c65e2915a14286a0ea922ae8325bde3561c1 --- /dev/null +++ b/sysdeps/aarch64/multiarch/strchr_sve2.S @@ -0,0 +1,116 @@ +/* Optimized strchr for SVE2. + Copyright (C) 2026 Free Software Foundation, Inc. + + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + . */ + +#include + +/* Assumptions: + * + * SVE2, unaligned accesses. + * + */ + +.arch armv9-a+sve2 + +#if defined (BUILD_STRCHRNUL) +#define STRCHR __strchrnul_sve2 +#else +#define STRCHR __strchr_sve2 +#endif + +#define chrin w1 // int chr. +#define result x0 // Return. + +#define src x0 // Current data pointer. +#define vlalign x2 // Alignment mask. +#define tmp x3 + +#define zdata z0 // Data. +#define zchr_nul z1 // chr and NUL data for search. + +#define pall p0 // All active predicate. +#define pchr_nul p1 // chr and NUL search result. +#define pchr p2 // chr search result. +#define psrc p3 // Mask of chars before srcin. +#define pfirst p4 // First found. + +ENTRY (STRCHR) + ptrue pall.b + and chrin, chrin, 0xff // Set zeros after first byte. + dup zchr_nul.h, chrin // Initialize chr and NUL for search. + + and tmp, src, 0xfff // Check for pagecross of 2VL reads. + incb tmp, all, mul #2 + tbnz tmp, 12, L(pagecross) + + ld1b {zdata.b}, pall/z, [src] + match pchr_nul.b, pall/z, zdata.b, zchr_nul.b + b.any L(firstmatch) + ld1b {zdata.b}, pall/z, [src, 1, mul vl] + match pchr_nul.b, pall/z, zdata.b, zchr_nul.b + b.none L(loop_start) + incb src +L(firstmatch): + brkb pfirst.b, pall/z, pchr_nul.b // Find first element. + incp src, pfirst.b // Increment by element index. +#if !defined (BUILD_STRCHRNUL) + cbz chrin, 1f // Special case NUL chrin. + cmpne pchr.b, pchr_nul/z, zdata.b, 0 // Matched chrin? + csel result, src, xzr, first // If it is NUL, return null. +1: ret + nop +#else + ret +#endif +L(loop_start): + mov vlalign, 0 + decb vlalign + and src, src, vlalign // Align src to VL. +L(loop): + ld1b {zdata.b}, pall/z, [src, 2, mul vl] + incb src, all, mul #2 + match pchr_nul.b, pall/z, zdata.b, zchr_nul.b + b.any L(loop_end) +L(loop2): + ld1b {zdata.b}, pall/z, [src, 1, mul vl] + match pchr_nul.b, pall/z, zdata.b, zchr_nul.b + b.none L(loop) + incb src +L(loop_end): + brkb pfirst.b, pall/z, pchr_nul.b // Find first element. + incp src, pfirst.b // Increment by element index. +#if !defined (BUILD_STRCHRNUL) + cbz chrin, 2f // Special case NUL chrin. + cmpne pchr.b, pchr_nul/z, zdata.b, 0 // Matched chrin? + csel result, src, xzr, first // If it is NUL, return null. +#endif +2: ret + + .p2align 3 +L(pagecross): + mov vlalign, 0 + decb vlalign + orn tmp, src, vlalign // Find end of VL aligned src. + whilels psrc.b, src, tmp // Mask off elements. + ld1b {zdata.b}, psrc/z, [src] + match pchr_nul.b, psrc/z, zdata.b, zchr_nul.b + b.any L(firstmatch) + and src, src, vlalign // Align src to VL. + b L(loop2) + +END (STRCHR) diff --git a/sysdeps/aarch64/strchr.S b/sysdeps/aarch64/strchr.S index e793fa92f15b63495eab94c83534c5830258bfec..daa28acbfc8b278897d47ec403dc945eb3ba3555 100644 --- a/sysdeps/aarch64/strchr.S +++ b/sysdeps/aarch64/strchr.S @@ -26,6 +26,10 @@ * MTE compatible. */ +#ifndef STRCHR +# define STRCHR strchr +#endif + #define srcin x0 #define chrin w1 #define result x0 @@ -51,7 +55,7 @@ zeroes gives the position of the matching byte if it is a multiple of 4. If it is not a multiple of 4, there was no match. */ -ENTRY (strchr) +ENTRY (STRCHR) bic src, srcin, 15 dup vrepchr.16b, chrin ld1 {vdata.16b}, [src] @@ -109,6 +113,6 @@ L(end): csel result, result, xzr, eq ret -END (strchr) -libc_hidden_builtin_def (strchr) -weak_alias (strchr, index) +END (STRCHR) +libc_hidden_builtin_def (STRCHR) +weak_alias (STRCHR, index)