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 The zero-extension of GPR4 isn't needed, and in fact, -O1 doesn't generate it: memset: cmpwi 0,5,0 beqlr 0 li 9,0 subf 5,9,5 mtctr 5 .L3: stbx 4,3,9 addi 9,9,1 bdnz .L3 blr (the subf here is superfluous though). -- Summary: Unnecessary zero-extension at -O2 but not -O1 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=41742