[Bug tree-optimization/32650] New: Convert p+strlen(p) to strchr(p, '\0') if profitable
kazu at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Fri Jul 6 15:53:00 GMT 2007
According to Mark Mitchell, strchr(p,'\0') is more efficient than
p+strlen(p).
#include <string.h>
void * f (char *p) { return p + strlen (p); }
void * g (char *p) { return strchr (p, '\0'); }
g:
xorl %esi, %esi
jmp __rawmemchr
f:
pushq %rbx
movq %rdi, %rbx
call strlen
leaq (%rbx,%rax), %rax
popq %rbx
ret
--
Summary: Convert p+strlen(p) to strchr(p, '\0') if profitable
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: enhancement
Priority: P3
Component: tree-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: kazu at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32650
More information about the Gcc-bugs
mailing list