https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62233
Oleg Endo <olegendo at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Target|powerpc64le |powerpc64le sh*-*-* Status|UNCONFIRMED |NEW Last reconfirmed| |2014-09-25 CC| |olegendo at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #2 from Oleg Endo <olegendo at gcc dot gnu.org> --- On SH, the original code above looks OK (no extra shifts generated), however, changing it to: void clear2 (S* s ) { int i; int len = s->l; int* p = s->b; for (i = 0; i < len; i++) p[i] = 0; } results in: mov.l @r4,r1 cmp/pl r1 bf/s .L13 add #4,r4 <<<< shll2 r1 <<<< add #-4,r1 <<<< shlr2 r1 <<<< mov #0,r2 add #1,r1 .align 2 .L10: mov.l r2,@r4 dt r1 bf/s .L10 add #4,r4 .L13: rts nop This looks very similar to what is happening in PR 55190. BTW, compiling the two functions with -O3 results in a detected memset, while at -O2 a memset is not detected.