From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/10507 Path: news.gmane.org!.POSTED!not-for-mail From: Georg Sauthoff Newsgroups: gmane.linux.lib.musl.general Subject: Re: memchr() performance Date: Tue, 20 Sep 2016 19:57:32 +0200 Message-ID: <20160920175732.GB7983@dell12.lru.li> References: <20160918185422.GA2577@dell12.lru.li> <20160918204036.GZ1280@port70.net> <20160919132953.GA8375@dell12.lru.li> <20160919175847.GA1280@port70.net> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1474394285 17459 195.159.176.226 (20 Sep 2016 17:58:05 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 20 Sep 2016 17:58:05 +0000 (UTC) User-Agent: Mutt/1.7.0 (2016-08-17) To: musl@lists.openwall.com Original-X-From: musl-return-10520-gllmg-musl=m.gmane.org@lists.openwall.com Tue Sep 20 19:57:57 2016 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1bmPIg-0002Sl-V1 for gllmg-musl@m.gmane.org; Tue, 20 Sep 2016 19:57:47 +0200 Original-Received: (qmail 18226 invoked by uid 550); 20 Sep 2016 17:57:45 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 18208 invoked from network); 20 Sep 2016 17:57:45 -0000 Content-Disposition: inline In-Reply-To: <20160919175847.GA1280@port70.net> Xref: news.gmane.org gmane.linux.lib.musl.general:10507 Archived-At: On Mon, Sep 19, 2016 at 07:58:48PM +0200, Szabolcs Nagy wrote: > * Georg Sauthoff [2016-09-19 15:29:53 +0200]: > > Yes. Sure, ub means that anything can happen, but this case should be ok > > with GCC - if the function is compiled in isolation in its own > > translation unit. > unless you use lto > (which musl does not support now, but ppl are doing this) Yes, with lto there is no isolation. For lto you can do one of the following: - write a version in pure assembler, doesn't have to be harder to read than a C version - use the may_alias attribute (supported at least by GCC/Clang) - apply the memcpy() trick: https://github.com/gsauthof/find-memchr/blob/master/find_avx2_memcpy_impl.cc Best regards Georg