public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: libc-alpha@sourceware.org
Subject: Re: [PATCH] Use strlen when searching for a nul char
Date: Tue, 19 Apr 2016 20:27:00 -0000	[thread overview]
Message-ID: <571694A4.4020603@linaro.org> (raw)
In-Reply-To: <20160419175706.GI5369@vapier.lan>



On 19-04-2016 14:57, Mike Frysinger wrote:
> 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
> 

Personally I am not very found on the string2.h header and its intrinsic logic,
which contains optimization logic that might not be true depending of the
architecture string optimization.

Also for the specific optimization does we really need to keep pushing for 
these specific inline implementations? I would prefer a much simple string2.h
header than a convoluted one we have today.

  reply	other threads:[~2016-04-19 20:27 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-25 13:10 Wilco Dijkstra
2016-04-15 12:36 ` Wilco Dijkstra
2016-04-19 17:57 ` Mike Frysinger
2016-04-19 20:27   ` Adhemerval Zanella [this message]
2016-04-19 20:51     ` Mike Frysinger
2016-04-19 21:01       ` Adhemerval Zanella
2016-04-19 21:23         ` Mike Frysinger
2016-04-19 22:03   ` Wilco Dijkstra
2016-04-19 22:21     ` Mike Frysinger
2016-04-20 14:50       ` Wilco Dijkstra
2016-04-20 15:24         ` Mike Frysinger
2016-04-20 15:53           ` Wilco Dijkstra
2016-05-12 14:05         ` Wilco Dijkstra
2016-06-03 12:38           ` Wilco Dijkstra
2016-06-21 13:37             ` Wilco Dijkstra
2016-04-20 15:31       ` Wilco Dijkstra
  -- strict thread matches above, loose matches on Subject: below --
2015-10-07 14:30 Wilco Dijkstra
2015-10-07 14:46 ` pinskia
2015-10-07 14:50   ` Wilco Dijkstra
2015-10-07 15:20   ` Joseph Myers
2015-10-07 15:30     ` Andreas Schwab
2015-10-07 16:40     ` Wilco Dijkstra
2015-10-07 17:17       ` Joseph Myers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=571694A4.4020603@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).