optimization/2963: Pointless moving (optimization)
Matthias Klose
doko@cs.tu-berlin.de
Sat May 26 11:46:00 GMT 2001
>Number: 2963
>Category: optimization
>Synopsis: Pointless moving (optimization)
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat May 26 11:45:59 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator: herbert@gondor.apana.org.au
>Release: 3.0 20010526 (Debian prerelease) (Debian testing/unstable)
>Organization:
Debian
>Environment:
System: Linux smile 2.2.17 #1 Sun Oct 8 19:26:41 MEST 2000 i686 unknown
Architecture: i686
host: i386-pc-linux-gnu
build: i386-pc-linux-gnu
target: i386-pc-linux-gnu
configured with: ../src/configure -v --enable-languages=c,c++,java,f77,proto,objc --prefix=/usr --infodir=/share/info --mandir=/share/man --enable-shared --with-gnu-as --with-gnu-ld --with-system-zlib --enable-long-long --enable-nls --without-x --without-included-gettext --disable-checking --enable-threads=posix --enable-java-gc=boehm --with-cpp-install-dir=bin --enable-objc-gc i386-linux
>Description:
I was wondering if gcc-3.0 can decrease the size of ash since it combines
those esp additions/subtractions. Unfortunately, it actually ends up being
bigger. Part of the reason for that may be this:
findstring:
pushl %ebp
movl %esp, %ebp
subl $20, %esp
pushl $pstrcmp
pushl $4
pushl 16(%ebp)
leal 8(%ebp), %edx
pushl 12(%ebp)
movl %edx, %eax
pushl %eax
call bsearch
leave
ret
Notice the line "movl %edx, %eax" is unnecessary if we push edx instead of
eax, or if we lea into eax instead of edx. The source of this is:
#include <stdlib.h>
int pstrcmp(const void *, const void *);
const char *const *findstring(
const char *s, const char *const *array, size_t nmemb
) {
return bsearch(&s, array, nmemb, sizeof(const char *), pstrcmp);
}
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the Gcc-bugs
mailing list