This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH 2/*] Optimize generic strchrnul and strchr
- From: Joseph Myers <joseph at codesourcery dot com>
- To: Ondřej Bílka <neleai at seznam dot cz>
- Cc: Wilco Dijkstra <wdijkstr at arm dot com>, <libc-alpha at sourceware dot org>
- Date: Thu, 28 May 2015 18:05:26 +0000
- Subject: Re: [PATCH 2/*] Optimize generic strchrnul and strchr
- Authentication-results: sourceware.org; auth=none
- References: <000d01d09879$ae9c2d80$0bd48880$ at com> <alpine dot DEB dot 2 dot 10 dot 1505281733001 dot 16930 at digraph dot polyomino dot org dot uk> <20150528175412 dot GA4872 at domone>
On Thu, 28 May 2015, Ondřej Bílka wrote:
> However it doesn't do it that well, I reported bug about that somewhere.
> So after all you need to make assembly dump and fix gcc mistakes.
>
> It don't eliminate ureachable checks when you put zero there, like for
>
> int
> foo(int x)
> {
> if (!x)
> return bar();
> return __builtin_ffsl(x);
> }
Well, if you don't care about the value for zero, using __builtin_clz is
an option (and guaranteed to expand to a libgcc call, not a call to ffs,
if not inlined, so no possible namespace issues).
--
Joseph S. Myers
joseph@codesourcery.com