https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55190
Alan Modra <amodra at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- Target|sh*-*-* arm*-*-* |sh*-*-* arm*-*-* | |powerpc*-*-* CC| |amodra at gmail dot com --- Comment #10 from Alan Modra <amodra at gmail dot com> --- Seen also on powerpc. Even for simple testcases like int b[30]; void fn1 (unsigned int n) { unsigned int i; for (i = 0; i < n; i++) b[i] = 42; } I see for -m32 fn1: cmpwi 0,3,0 beq 0,.L1 slwi 9,3,2 #### lis 10,b-4@ha addi 9,9,-4 #### la 10,b-4@l(10) srwi 9,9,2 #### li 8,42 addi 9,9,1 #### mtctr 9 .p2align 4,,15 .L3: stwu 8,4(10) bdnz .L3 .L1: blr All of the insns marked #### are redundant. For -m64 this loop doesn't even use bdnz Loop 1 is simple: simple exit 4 -> 5 infinite if: (expr_list:REG_DEP_TRUE (ne:SI (and:DI (plus:DI (minus:DI (ashift:DI (reg:DI 189) (const_int 2 [0x2])) (reg:DI 179 [ ivtmp.7 ])) (symbol_ref:DI ("b") [flags 0x80] <var_decl 0x7fe7521de870 b>)) (const_int 3 [0x3])) (const_int 0 [0])) (nil)) number of iterations: (lshiftrt:DI (plus:DI (minus:DI (reg:DI 185 [ _18 ]) (reg:DI 179 [ ivtmp.7 ])) (const_int -4 [0xfffffffffffffffc])) (const_int 2 [0x2])) upper bound: 29 likely upper bound: 29 realistic bound: -1 Doloop: Possible infinite iteration case. Doloop: The loop is not suitable.