This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug optimization/3508] builtin memcmp() could be optimised
- From: "debian-gcc at lists dot debian dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 10 Aug 2003 15:31:05 -0000
- Subject: [Bug optimization/3508] builtin memcmp() could be optimised
- References: <20010701092600.3508.85535-quiet@bugs.debian.org>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3508
debian-gcc at lists dot debian dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |herbert at gondor dot apana
| |dot org dot au
------- Additional Comments From debian-gcc at lists dot debian dot org 2003-08-10 15:31 -------
Unfortunately this bug has only been special cased rather than fixed
in its full generality. If we change one of the arguments to a
variable, the compiler still fails to produce the dword comparison
that I would expect:
-- a.c --
int foo(const char *s) {
return !memcmp("abcd", s, 4);
}
-- gcc -S -O2 a.c --
.LC0:
.string "abcd"
.text
.p2align 2,,3
.globl foo
.type foo, @function
foo:
pushl %ebp
movl %esp, %ebp
pushl %edi
pushl %esi
movl 8(%ebp), %edi
movl $.LC0, %esi
movl $4, %ecx
cld
repz
cmpsb
sete %al
popl %esi
movzbl %al, %eax
popl %edi
leave
ret
.size foo, .-foo
.ident "GCC: (GNU) 3.3 20030509 (Debian prerelease)"
--