Name: Anonymous 2009-05-28 17:25
Does anyone know if GCC v4.x optimizes automatically the incr i++; to ++i; ?
% gcc -O1 -S a.c; gcc -S b.c
% diff a.s b.s
9,10d8
< pushl %edi
< pushl %esi
12,13c10,11
< subl $28, %esp
< call L7
---
subl $36, %esp
call L6
15c13
< L7:
---
L6:
17,20c15,19
< movl $10, %esi
< leal LC0-"L00000000001$pb"(%ebx), %edi
< L2:
< movl %edi, (%esp)
---
movl $0, -12(%ebp)
jmp L2
L3:
leal LC0-"L00000000001$pb"(%ebx), %eax
movl %eax, (%esp)
22,23c21,25
< decl %esi
< jne L2
---
leal -12(%ebp), %eax
incl (%eax)
L2:
cmpl $9, -12(%ebp)
jle L3
25c27
< addl $28, %esp
---
addl $36, %esp
27,28d28
< popl %esi
< popl %edi
% gcc --version
i686-apple-darwin9-gcc-4.0.1 (GCC) 4.0.1 (Apple Inc. build 5465)
Copyright (C) 2005 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
%