This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/17640] New: empty loop not removed after optimization
- From: "wouter dot vermaelen at pi dot be" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 23 Sep 2004 21:13:44 -0000
- Subject: [Bug c/17640] New: empty loop not removed after optimization
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
gcc can optimize this program quite well. However the remaining empty loop is a
bit silly.
int f() { return 1; }
int main() {
int a = 0;
for (int i = 0; i < 100; ++i) {
a += f();
}
return a;
}
> gcc loop.c -O3 -S
main: pushl %ebp
movl %esp, %ebp
subl $8, %esp
andl $-16, %esp
subl $16, %esp
movl $99, %eax
.L7: decl %eax
jns .L7
movl $100, %eax
leave
ret
--
Summary: empty loop not removed after optimization
Product: gcc
Version: 3.4.2
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: wouter dot vermaelen at pi dot be
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17640