public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: optimization/3511: Inlined strlen() could be smarter
@ 2002-10-06 20:05 rth
0 siblings, 0 replies; 2+ messages in thread
From: rth @ 2002-10-06 20:05 UTC (permalink / raw)
To: 86251-quiet, gcc-bugs, gcc-prs, herbert, nobody
Synopsis: Inlined strlen() could be smarter
State-Changed-From-To: open->suspended
State-Changed-By: rth
State-Changed-When: Sun Oct 6 20:05:04 2002
State-Changed-Why:
I doubt this will ever be handled.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=3511
^ permalink raw reply [flat|nested] 2+ messages in thread
* optimization/3511: Inlined strlen() could be smarter
@ 2001-07-01 9:36 Matthias Klose
0 siblings, 0 replies; 2+ messages in thread
From: Matthias Klose @ 2001-07-01 9:36 UTC (permalink / raw)
To: gcc-gnats, debian-gcc
>Number: 3511
>Category: optimization
>Synopsis: Inlined strlen() could be smarter
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Jul 01 09:36:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator: herbert@gondor.apana.org.au
>Release: 3.0 (Debian GNU/Linux) and HEAD 20010701
>Organization:
The Debian project
>Environment:
System: Debian GNU/Linux (testing/unstable)
Architecture: i686
host: i386-linux
build: i386-linux
target: i386-linux
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-included-gettext --disable-checking --enable-threads=posix --enable-java-gc=boehm --with-cpp-install-dir=bin --enable-objc-gc i386-linux
>Description:
[ Reported to the Debian BTS as report #86251.
Please CC 86251-quiet@bugs.debian.org on replies.
Log of report can be found at http://bugs.debian.org/86251 ]
gcc -S -O2 on the file
#include <string.h>
size_t mystrlen(const char *s) {
if (!s) {
s = "";
}
return strlen(s);
}
generates (on i386)
.file "bug-86251.c"
.section .rodata
.LC0:
.string ""
.text
.align 2
.p2align 2,,3
.globl mystrlen
.type mystrlen,@function
mystrlen:
pushl %ebp
movl %esp, %ebp
pushl %edi
movl 8(%ebp), %edi
testl %edi, %edi
je .L114
.L113:
xorl %eax, %eax
cld
movl $-1, %ecx
repnz
scasb
notl %ecx
leal -1(%ecx), %eax
movl (%esp), %edi
leave
ret
.p2align 2,,3
.L114:
movl $.LC0, %edi
jmp .L113
.Lfe1:
.size mystrlen,.Lfe1-mystrlen
.ident "GCC: (GNU) 3.1 20010701 (experimental)"
As you can see, strlen() is not optimised out in the !pat case.
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2002-10-07 3:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-06 20:05 optimization/3511: Inlined strlen() could be smarter rth
-- strict thread matches above, loose matches on Subject: below --
2001-07-01 9:36 Matthias Klose
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).