Number of loop iterations is calculated wrongly in the following bit of code.
extern char __dp0 ; extern const long __reloc_table ; extern const int __reloc_num ; void foo (void) { register char *dp = 0; int cpu; const long *reloc_ptr; unsigned int num_relocs = 0; dp = &__dp0; for (reloc_ptr = &__reloc_table, num_relocs = (unsigned int)&__reloc_num;num_relocs; reloc_ptr++,num_relocs--) *(long *)(dp + *reloc_ptr) += (long)dp; } Code generated for : ./xgcc -B`pwd` -S -O3 -mregnames ~/tmp/fails.i is foo: lis %r9,[EMAIL PROTECTED] lis %r11,[EMAIL PROTECTED] la %r8,[EMAIL PROTECTED](%r9) lis %r9,[EMAIL PROTECTED] la %r9,[EMAIL PROTECTED](%r9) la %r11,[EMAIL PROTECTED](%r11) mtctr %r9 mr %r10,%r8 .L4: lwz %r9,0(%r11) addi %r11,%r11,4 lwzx %r0,%r9,%r10 add %r0,%r0,%r8 stwx %r0,%r9,%r10 bdnz .L4 blr This bug seems to appear after the ivopts backport. .08.jump has a check for the loop counter to be 0 which 09.cse removes as trivially dead. I would expect there to be a check for the loop counter to be zero before the body of the loop. -- Summary: invalid loop transformation. Product: gcc Version: 4.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: rtl-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: ramana dot radhakrishnan at codito dot com GCC build triplet: i686-pc-linux GCC host triplet: i686-pc-linux GCC target triplet: powerpc-elf http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27625