http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50136
Bug #: 50136
Summary: Loop inc/dec optimization.
Classification: Unclassified
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: [email protected]
ReportedBy: [email protected]
Maybe shoud use inc and dec, than sub $1, %ebx?
GCC translate this C code:
unsigned int i;
scanf("%u", &i);
for(unsigned int qwe=i; qwe>0; qwe--)
printf("fg");
Into this Assembler code:
leaq 12(%rsp), %rsi
xorl %eax, %eax
movl $.LC0, %edi
call __isoc99_scanf
movl 12(%rsp), %ebx
testl %ebx, %ebx
je .L2
.p2align 4,,10
.p2align 3
.L4:
xorl %eax, %eax
movl $.LC1, %edi
call printf
subl $1, %ebx ;This not good, dec %ebx is better
jne .L4