https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111500
--- Comment #2 from Luke <gnu.arne at wgboome dot org> --- (In reply to Andrew Pinski from comment #1) > Can you attach (compilible) examples code for each issue? Really these > should be filed seperately too. do u mean, i should file 3 further bug reports? i try examples for artifact #1 first... is it right like this? example code for artifact #1a: // "cmp" follows the "subs" immediately __attribute((noinline)) void artiSUBS() { for (int i=100; i>0; i--) 200017ec: 2364 movs r3, #100 ; 0x64 *(volatile int*)0xE000E014 = i; 200017ee: 4a03 ldr r2, [pc, #12] ; (200017fc) 200017f0: 6013 str r3, [r2, #0] for (int i=100; i>0; i--) 200017f2: 3b01 subs r3, #1 200017f4: 2b00 cmp r3, #0 200017f6: d1fb bne.n 200017f0 } 200017f8: 4770 bx lr 200017fa: 46c0 nop 200017fc: e000e014 example code for artifact #1b: // gcc tends to do the "i--" too early; "ldr" does not touch flags // maybe because it hopes to get beneficial pipeline effects at loop entry? __attribute((noinline)) void artiSUBS() { 200017ec: 2364 movs r3, #100 ; 0x64 for (int i=100; i>0; i--) (void) *(volatile int*)0xE000E014; 200017ee: 4a03 ldr r2, [pc, #12] ; (200017fc) 200017f0: 3b01 subs r3, #1 200017f2: 6811 ldr r1, [r2, #0] for (int i=100; i>0; i--) 200017f4: 2b00 cmp r3, #0 200017f6: d1fb bne.n 200017f0 } 200017f8: 4770 bx lr 200017fa: 46c0 nop 200017fc: e000e014