svn commit: r213326 - head/lib/libc/i386/string

Dimitry Andric dim at FreeBSD.org
Fri Oct 1 15:28:03 UTC 2010


On 2010-10-01 15:22, Roman Divacky wrote:
> there's "rep cmps" in bcmp.S and memcmp.S in both amd64/i386
>
> they both have C counterparts, no idea how fast those are (they
> are going char by char).
>
> does this wisdom apply to those too?

Well, these versions compare by words first, using "repe cmpsl" (for
i386) and "rep cmpsq" (for amd64).  Only if there any bytes remaining
after that, they are checked with "repe cmpsb".

It is probably possible to optimize these versions for the case the
source pointers are not aligned.  That will not occur too much,
probably, and complicate the implementation.

On the other hand, the C implementations of bcmp and memcmp are
basically simple "while (*src++ == *dst++);" implementations, so it is
entirely up to the compiler to do any optimization magic there.

In any case, without some statistically sane speed measurements, this is
all just talk... ;)


More information about the svn-src-all mailing list