Simple testcase: /* { dg-do compile } */ /* { dg-options "-O2" } */
int f(int l, int *a) { int i; for(i = 0;i < l; i++) a[i] = i; return l; } /* We should be able to do this loop without adding -1 to the l to get the number of iterations with this loop still doing a do-loop. */ /* The place where we were getting an extra -1 is when converting from 32bits to 64bits as the ctr register is used as 64bits on powerpc64. */ /* { dg-final { scan-assembler-not "-1" } } */ /* { dg-final { scan-assembler "bdnz" } } */ /* { dg-final { scan-assembler-times "mtctr" 1 } } */ ---- CUT --- The issue is that we zero extend before correcting the count of the iterations. -- Summary: Extra addition for doloop in some cases Product: gcc Version: 4.4.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: enhancement Priority: P3 Component: rtl-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: pinskia at gcc dot gnu dot org GCC target triplet: powerpc64-*-* http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37451