From patchwork Fri May 27 13:29:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wilco Dijkstra X-Patchwork-Id: 627150 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rGRhf0f05z9sC4 for ; Fri, 27 May 2016 23:30:09 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b=mAejt98b; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id :mime-version:content-type:content-transfer-encoding; q=dns; s= default; b=tLhQIrZss27I48LvSgJbXRlPY3BxGs8Aj/wIAv72GC9/ONj/lh37B /eoGq8AT2bAWiVTOoUOwUPjq8+l1SmSlbDZJQnl3MNS8xYL5MbPH93qVMUr0j87G 7ER1LCsBrzYvUD0O1eZWzH8Te8QHVaBT36thP7SNPXLXbUELSCiIk0= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id :mime-version:content-type:content-transfer-encoding; s=default; bh=zQ9UlMjCv1JqW22ByXVEZYr3hdM=; b=mAejt98bqJ+EByHZhs6iACPmzIn3 5J3h9GXcK/pJDnIaJpz/DX+4eqZiYZS/JsxzWuaIdD6F24PhCNU8+111K9+0svW8 9cvvIPD+EgV6qIVqGWXzx4VER5e++qRJmPWFRx4xQLffmPASdTQbGPSZfML4W8YP 3YuqFHEG90eYZI0= Received: (qmail 115945 invoked by alias); 27 May 2016 13:29:54 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 115818 invoked by uid 89); 27 May 2016 13:29:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00, SPF_PASS autolearn=ham version=3.3.2 spammy=x14, Hx-spam-relays-external:sk:EUR01-D, H*RU:sk:EUR01-D, H*MI:outlook X-HELO: eu-smtp-delivery-143.mimecast.com From: Wilco Dijkstra To: 'GNU C Library' CC: nd Subject: [PATCH][AArch64] Add rawmemchr Date: Fri, 27 May 2016 13:29:37 +0000 Message-ID: x-ms-office365-filtering-correlation-id: 7057c3df-563d-43ae-50cf-08d38632f320 x-microsoft-exchange-diagnostics: 1; AM3PR08MB0085; 5:JxRTZAow0Tt6Bcgplm5AveY8pm4lobvrK8kIchwhouH9kpl9LKfb7XuHaph2uwItgspyB8CxfTjYvGS1E4jbwd1BNmvTEzD+45GDkHXMedTG0d5jTNNj3cOYvynlKHeLJy2lUIrbUlWj7QN9/XZjtA==; 24:O9bWlcJ40dZqXs3n99viep4BHGLFI95J93BRS8a+qZZt0NyIdAXXnes3ux7+TmQTWbZA0kOiCURTbnJ4tC07Vl1nLe7+baQdQGAR2PeI/iM=; 7:20Eh2W3txBkZHbsElw7Jn3XtUIWaGRwwStd0l9YW8cllbs7Foj/pddiSLWheB0wQVtaL28rluycfPGdYSCK+/esgbZJoK0gz2loUgzct6DoMFZBPCaW9HKpE+8YRmvb+RBm5GY1Vabr/6Vv8XFYeGp4iIyikebbNTkPxqt8F8Ck1asR0pWCBQGCoER99+R/m; 20:58KW3/DV/0sf+LK1WU55ATgE8Ob2xYKwOQa0C/z9I7EoTDtX4SihhDbVq4AlalVk6JVX3I7yBWqrZT6BWpeHGYwqgqLOPhK0J+V3fdgoV89xHO1iP6uXeXyQZ+Ci40iaa53TGwOiYj94mXM9RhoPIG78MaJAcSzwuT66gvYLRts= x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:AM3PR08MB0085; nodisclaimer: True x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(250305191791016)(180628864354917)(22074186197030); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6055026); SRVR:AM3PR08MB0085; BCL:0; PCL:0; RULEID:; SRVR:AM3PR08MB0085; x-forefront-prvs: 09555FB1AD x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(377424004)(54534003)(1220700001)(6116002)(19580395003)(102836003)(3846002)(586003)(19580405001)(4326007)(2906002)(229853001)(5008740100001)(5250100002)(5004730100002)(450100001)(33656002)(66066001)(11100500001)(74316001)(15975445007)(5003600100002)(2900100001)(76576001)(50986999)(86362001)(5002640100001)(54356999)(87936001)(92566002)(8936002)(110136002)(189998001)(106116001)(8676002)(81166006)(9686002)(3660700001)(3280700002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM3PR08MB0085; H:AM3PR08MB0088.eurprd08.prod.outlook.com; FPR:; SPF:None; MLV:sfv; LANG:en; spamdiagnosticoutput: 1:23 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-originalarrivaltime: 27 May 2016 13:29:37.2808 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM3PR08MB0085 X-MC-Unique: mwygbbWZQ2etNCEqt6WnVw-1 Add a simple rawmemchr implementation. Use strlen for rawmemchr(s, '\0') as it is the fastest way to search for '\0'. Otherwise use memchr with an infinite size. This is 3x faster on benchtests for large sizes. Passes GLIBC tests, OK for commit? ChangeLog: 2016-05-27 Wilco Dijkstra * sysdeps/aarch64/rawmemchr.S (__rawmemchr): New file. * sysdeps/aarch64/strlen.S (__strlen): Change to __strlen to avoid PLT. --- sysdeps/aarch64/rawmemchr.S | 42 ++++++++++++++++++++++++++++++++++++++++++ sysdeps/aarch64/strlen.S | 5 +++-- 2 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 sysdeps/aarch64/rawmemchr.S diff --git a/sysdeps/aarch64/rawmemchr.S b/sysdeps/aarch64/rawmemchr.S new file mode 100644 index 0000000..ec958e8 --- /dev/null +++ b/sysdeps/aarch64/rawmemchr.S @@ -0,0 +1,42 @@ +/* rawmemchr - find a character in a memory zone + + Copyright (C) 2015-2016 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 + +/* Special case rawmemchr (s, 0) as strlen, otherwise tailcall memchr. + Call strlen without setting up a full frame - it preserves x14/x15. +*/ + +ENTRY (__rawmemchr) + cbz w1, L(do_strlen) + mov x2, -1 + b __memchr + +L(do_strlen): + mov x15, x30 + cfi_return_column (x15) + mov x14, x0 + bl __strlen + add x0, x14, x0 + ret x15 + +END (__rawmemchr) +weak_alias (__rawmemchr, rawmemchr) +libc_hidden_builtin_def (__rawmemchr) diff --git a/sysdeps/aarch64/strlen.S b/sysdeps/aarch64/strlen.S index feb9e48..e2a4363 100644 --- a/sysdeps/aarch64/strlen.S +++ b/sysdeps/aarch64/strlen.S @@ -84,7 +84,7 @@ whether the first fetch, which may be misaligned, crosses a page boundary. */ -ENTRY_ALIGN (strlen, 6) +ENTRY_ALIGN (__strlen, 6) and tmp1, srcin, MIN_PAGE_SIZE - 1 mov zeroones, REP8_01 cmp tmp1, MIN_PAGE_SIZE - 16 @@ -213,5 +213,6 @@ L(page_cross): csel data1, data1, tmp4, eq csel data2, data2, tmp2, eq b L(page_cross_entry) -END (strlen) +END (__strlen) +weak_alias (__strlen, strlen) libc_hidden_builtin_def (strlen)