This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Re: Volunteer to rewrite string functions
- To: libc-alpha at sources dot redhat dot com
- Subject: Re: Volunteer to rewrite string functions
- From: Paolo Bonzini <bonzini at pc-amo3 dot elet dot polimi dot it>
- Date: Tue, 27 Feb 2001 17:05:09 +0100 (CET)
- Reply-To: bonzini at gnu dot org
MMX was just a boutade, for personal information. I do have a MMX strlen
that runs at 0.75 clock cycles per byte, but you are right when you say
that it is nonsense without performance information. I don't expect that
an application mingles floating point and string operations in an inner
loop, but performance would surely be very badly hurt in that case.
But for the other functions and for non-MMX assembly language
implementations, performance improvements should be clear since in most
cases I am going to use *exactly* the same algorithm, with *the same*
startup costs, but tuned so that there are *no* false positives (and hence
with a bytes/clock cycle ratio that can be calculated precisely at least
on the Pentium).
For strrchr I am modifying the strchr code so that it saves the last
occurrence of the character and only returns when the zero is found. That
is:
ret_ptr = NULL;
...
if (cp[0] == c)
ret_ptr = cp;
if (cp[0] == 0)
return ret_ptr;
if (cp[1] == c)
ret_ptr = cp + 1; /* CSE removes this add */
if (cp[1] == 0)
return ret_ptr;
...
Again, performance improvements should be clear with respect to the
current implementation, because we do the alignment just once, instead of
every time C is found.
|_ _ _ ___
|_)(_)| ) ,'
--------- '-._.