HEADS DOWN
Andrey Chernov
ache at freebsd.org
Sat May 5 21:32:14 UTC 2007
On Sat, May 05, 2007 at 03:56:21PM -0500, Sean C. Farley wrote:
> Interestingly, gcc 3.4.6 on -STABLE does not do such a great job even
> with -minline-all-stringops. I do have CPUTYPE?=pentium4 in
> /etc/make.conf. Maybe this is only an issue with i386 similar to what
> you mention below?
Even "cc -O" do that, without any flags, see live example below:
a.c:
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
main() {
printf("%d\n", strlen(getenv("HOME")));
}
cc -O -S a.c
cat a.s
.file "a.c"
.section .rodata.str1.1,"aMS", at progbits,1
.LC0:
.string "HOME"
.LC1:
.string "%d\n"
.text
.p2align 2,,3
.globl main
.type main, @function
main:
pushl %ebp
movl %esp, %ebp
pushl %edi
subl $4, %esp
andl $-16, %esp
subl $28, %esp
pushl $.LC0
call getenv
addl $8, %esp
movl %eax, %edi
cld
movl $-1, %ecx
movb $0, %al
repnz
scasb
notl %ecx
decl %ecx
pushl %ecx
pushl $.LC1
call printf
movl -4(%ebp), %edi
leave
ret
.size main, .-main
.ident "GCC: (GNU) 3.4.6 [FreeBSD] 20060825"
--
http://ache.pp.ru/
More information about the freebsd-arch
mailing list