Take the following example: void *memset(void *b, int c, unsigned long len) { unsigned long i;
for (i = 0; i < len; i++) ((unsigned char *)b)[i] = c; return b; } -O2 generates: memset: cmpwi 0,5,0 beqlr 0 mtctr 5 rlwinm 4,4,0,0xff li 9,0 .p2align 4,,15 .L3: stbx 4,3,9 addi 9,9,1 bdnz .L3 blr but -Os does: memset: cmpwi 7,5,0 li 9,0 addi 5,5,1 bne+ 7,.L2 li 5,1 b .L2 .L3: stbx 4,3,9 addi 9,9,1 .L2: addic. 5,5,-1 bne 0,.L3 blr which is much worse and bigger. -- Summary: -Os generates bigger code than -O2 for simple loops Product: gcc Version: 4.5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: segher at kernel dot crashing dot org GCC target triplet: powerpc-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41741