This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 2/*] Optimize generic strchrnul and strchr


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]