From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 121246 invoked by alias); 19 Apr 2016 17:57:11 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 121220 invoked by uid 89); 19 Apr 2016 17:57:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 spammy=Strlen, H*MI:sk:DB3PR08 X-HELO: smtp.gentoo.org Date: Tue, 19 Apr 2016 17:57:00 -0000 From: Mike Frysinger To: Wilco Dijkstra Cc: 'GNU C Library' , nd Subject: Re: [PATCH] Use strlen when searching for a nul char Message-ID: <20160419175706.GI5369@vapier.lan> Mail-Followup-To: Wilco Dijkstra , 'GNU C Library' , nd References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="4/KhLkEx1OUQso4T" Content-Disposition: inline In-Reply-To: X-SW-Source: 2016-04/txt/msg00467.txt.bz2 --4/KhLkEx1OUQso4T Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-length: 750 On 25 Feb 2016 13:04, Wilco Dijkstra wrote: > Remove the strchr (s, '\0') to rawmemchr optimization as using rawmemchr is > a bad idea - I have a patch to add strchr (s, '\0') -> strlen to GCC7. > Like strchr (s, '\0'), rawmemchr (s, '\0') appears a common idiom for finding > the end of a string, however it is not the most efficient way of doing so. > Strlen is a simpler operation which is significantly faster on larger inputs > (eg. on x86 strlen is 50% faster than rawmemchr on strings of 1KB). will there be a change in GCC to also detect rawmemchr(s,'\0') ? even then, since this optimization isn't showing up until GCC7, shouldn't we keep some logic here ? i.e. transform strchr/rawmemchr(s, '\0') into strlen before falling back ? -mike --4/KhLkEx1OUQso4T Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-length: 819 -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJXFnFyAAoJEEFjO5/oN/WBpC4P/0FLqHEkXA0c0NJbGRv3TONV PwiNrmUPsEDvrFXrmaLYn0Q2wHgZHwmrEVgEa0BIAq+NMKHvl+BkS8Sd9zv8+OJe yIcFknQZEBNwRjNDO3dJL6SxhAJv+4cZzWJd+6zFjw/NZksoi742ILaR1UWg6sWi VB6OwGBU5Gxrw0TxYMmblA2rS+gZPlBvv6bKcb/BRDAXREzin3cln7vWaZsK/j7T DwR0S20/KvZBN+PHK8jbiaYi99Kzs+ztfiDoZDPF7kc12BAqXPt41YfGbndUUV3Q vvqCx+sECWSgxlTiM9uKvVQe512IcGq3eAU8rm2Vz/5hVvZuYCWez48129AySkUS H1Hf+sCSZU/Xj1OrGwWWP2ybb8TTXTkYMAAE+APIpX7h73W/NWF3yuFA/A0SRnn7 EfdlaEe52TFsryjXu2XMwSaijRTHCOhYudi/OURvF8vVfYI/3Eul3lqCj2H/RWn2 yrI2hMM77Jc5RXL6M5U0xcQSu0dL6HfBVZIspG2vq1WJgmIxDpmaNayvt3fVmfnR y5IOJXIEqCTPhUOUeyLd839B2MvNF+yRejyO7L/JjYXwBRlPKA/aZkMOTTzY/huY 4k0B6SwTNyxIR8YxXVX/P9BtTnL/zzkrgHV3h1zJLBe688uF9kXdD4a3Tgqu1TCZ EXcRHh4GDhNp/w7YSnlK =YBYe -----END PGP SIGNATURE----- --4/KhLkEx1OUQso4T--