This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
[i386] memcmp very slow
- From: "Bonzini" <bonzini at gnu dot org>
- To: <gcc at gcc dot gnu dot org>
- Cc: <libc-alpha at sources dot redhat dot com>
- Date: Mon, 28 Oct 2002 18:39:22 +0100
- Subject: [i386] memcmp very slow
I think that the pattern that is used when inlining memcmp for the i386
should be disabled, except perhaps at -Os. cmpsb is completely unoptimized
in the latest and not-so-latest processors (from the Pentium on).
Here are the results of timing a hand-written memcmp that I just submitted
to the libc-alpha mailing list (including call-return overheads) vs. the GCC
inline memcmp:
utente@engineer:~/esperimenti$ gcc -g -O3 -fno-builtin test.c memcmp.S
utente@engineer:~/esperimenti$ time ./a.out
real 0m0.088s
user 0m0.090s
sys 0m0.000s
utente@engineer:~/esperimenti$ gcc -g -O3 test.c
utente@engineer:~/esperimenti$ time ./a.out
real 0m0.102s
user 0m0.100s
sys 0m0.010s
The results that the inlined memcmp gives compared the current glibc memcmp
seem to be encouraging:
utente@engineer:~/esperimenti$ gcc -g -O3 -fno-builtin test.c
utente@engineer:~/esperimenti$ time ./a.out
real 0m0.108s
user 0m0.100s
sys 0m0.010s
but this is only because glibc has a poor implementation of memcmp for the
i386 which also is nothing more than a cmpsb.
The handwritten assembly language memcmp implementation that I refer to is
available at http://sources.redhat.com/ml/libc-alpha/2002-10/msg00496.html
Paolo Bonzini