This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]