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: Optimized? strchr implementations.


On Tue, May 26, 2015 at 09:58:01AM -0700, Matt Turner wrote:
> On Tue, May 26, 2015 at 7:38 AM, OndÅej BÃlka <neleai@seznam.cz> wrote:
> > On Tue, May 26, 2015 at 01:23:36PM +0100, Wilco Dijkstra wrote:
> >> > OndÅej BÃlka wrote:
> >> > On Sun, May 24, 2015 at 06:32:14PM +0200, OndÅej BÃlka wrote:
> >> > > Hi,
> >> > > this is nontrivial optimization of string inlines.
> >> > > First it decreases icache pressure as you don't need strchr.
> >>
> >> It's not obvious to me that is the right thing to do. Generally it is best
> >> to use the standard C90/C99 functions rather than infrequently used
> >> non-standard ones. A quick grep of GLIBC shows strchr is used a lot more
> >> than strchrnul, and 9 targets have an optimized strchr vs 5 for strchrnul.
> >>
> > I looked at how architectures optimize strchr and that number is less.
> >
> > Some of these are not optimized implementations. If you do gcc
> > string/strchr.c -S then you get assembly implementation. Several
> > architectures don't exploit any hardware capabilities, just use same
> > algorithm as generic so these could be deleted.
> >
> > I know that generic implementation could be improved and will post a
> > patches.
> >
> > Only two that are real optimizations and don't have strchnul are armv6
> > and alpha
> > So could you adapt armv6 one?
> >
> > Richard as you added alpha could you adapt it to strchnul? And why you
> > do a binary search there? Accoring to wiki alpha supports ctlz
> > instruction that does exactly that.
> 
> It's because Alphas < EV67 don't have ctlz.

OK. You could try optimize it bit by implementing ctl with
multiplication but that likely doesn't matter.


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