[PATCH 2/*] Optimize generic strchrnul and strchr
Joseph Myers
joseph@codesourcery.com
Thu May 28 20:36:00 GMT 2015
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
More information about the Libc-alpha
mailing list