This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/50136] New: Loop inc/dec optimization.
- From: "bratsinot at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 20 Aug 2011 05:49:46 +0000
- Subject: [Bug c/50136] New: Loop inc/dec optimization.
- Auto-submitted: auto-generated
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: unassigned@gcc.gnu.org
ReportedBy: bratsinot@gmail.com
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