https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78824
Freddie Chopin <freddie_chopin at op dot pl> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |freddie_chopin at op dot pl --- Comment #3 from Freddie Chopin <freddie_chopin at op dot pl> --- Works fine on arm-none-eabi- on -O1, -O2, -O3: y = nvx8 + nvx8 + nvx8 + nvx8 + nvx8 + nvx8 + nvx8 + nvx8 + nvx8 + nvx8 + nvx8 + nvx8 + nvx8 + nvx8 + nvx8 + nvx8; 80001e4: 4b03 ldr r3, [pc, #12] ; (80001f4 <main+0x10>) 80001e6: 4a04 ldr r2, [pc, #16] ; (80001f8 <main+0x14>) 80001e8: 781b ldrb r3, [r3, #0] 80001ea: 011b lsls r3, r3, #4 80001ec: 8013 strh r3, [r2, #0] However on -Os suboptimal (and actually longer) code is generated: y = nvx8 + nvx8 + nvx8 + nvx8 + nvx8 + nvx8 + nvx8 + nvx8 + nvx8 + nvx8 + nvx8 + nvx8 + nvx8 + nvx8 + nvx8 + nvx8; 8008ef6: 4b75 ldr r3, [pc, #468] ; (80090cc <main+0x1d8>) 8008efa: 781a ldrb r2, [r3, #0] 8008efc: eb02 03c2 add.w r3, r2, r2, lsl #3 8008f00: eb03 0382 add.w r3, r3, r2, lsl #2 8008f04: eb03 0342 add.w r3, r3, r2, lsl #1 8008f08: 4413 add r3, r2 8008f0a: 4a71 ldr r2, [pc, #452] ; (80090d0 <main+0x1dc>) 8008f0c: b29b uxth r3, r3 8008f0e: 8013 strh r3, [r2, #0] Similar code is generated for -Og.