[Bug c/17640] New: empty loop not removed after optimization

wouter dot vermaelen at pi dot be gcc-bugzilla@gcc.gnu.org
Thu Sep 23 21:13:00 GMT 2004


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



More information about the Gcc-bugs mailing list