Given this simple program: main() { int i; for (i = 0; i < 10; i++) f2(); }
compiled with -O2 gcc33-hammer detects that the loop index is not used in the loop body and rewrites it to a downwards counting loop, elimitinating one instruction (inc/cmp -> dec) movl $9, %ebx .p2align 4,,7 .L6: xorl %eax, %eax call f2 decl %ebx jns .L6 popq %rbx but gcc 4.0 - 4.3 don't anymore (tried 4.1, 4.3 and 4.4): xorl %ebx, %ebx .p2align 4,,7 .L2: xorl %eax, %eax incl %ebx call f2 cmpl $10, %ebx jne .L2 -- Summary: No loop counter reversal for simple loops anymore Product: gcc Version: 4.4.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: regression AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: andi-gcc at firstfloor dot org GCC host triplet: x86_64-linux GCC target triplet: x86_64-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40886