https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93800
Bug ID: 93800 Summary: GCC adds unwanted nops to align loops on powerpc 8xx Product: gcc Version: 9.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: christophe.le...@c-s.fr Target Milestone: --- GCC 9.2 add nops in front of loops. GCC 8.1 didn't when compiled for powerpc 8xx. On the 8xx, a nop is 1 cycle and alignment of loops provide no benefit, so this is a waste of cycles. Reproducer: volatile int g; int f(int a, int b) { int i; for (i = 0; i < b; i++) a += g; return a; } Built with -m32 -mcpu=860 -O2 00000000 <f>: 0: 2c 04 00 00 cmpwi r4,0 4: 4c 81 00 20 blelr 8: 3d 40 00 00 lis r10,0 a: R_PPC_ADDR16_HA g c: 7c 89 03 a6 mtctr r4 10: 39 4a 00 00 addi r10,r10,0 12: R_PPC_ADDR16_LO g 14: 60 00 00 00 nop 18: 60 00 00 00 nop 1c: 60 00 00 00 nop 20: 81 2a 00 00 lwz r9,0(r10) 24: 7c 63 4a 14 add r3,r3,r9 28: 42 00 ff f8 bdnz 20 <f+0x20> 2c: 4e 80 00 20 blr The same with GCC 8.1: 00000000 <f>: 0: 2c 04 00 00 cmpwi r4,0 4: 4c 81 00 20 blelr 8: 3d 40 00 00 lis r10,0 a: R_PPC_ADDR16_HA g c: 7c 89 03 a6 mtctr r4 10: 39 4a 00 00 addi r10,r10,0 12: R_PPC_ADDR16_LO g 14: 81 2a 00 00 lwz r9,0(r10) 18: 7c 63 4a 14 add r3,r3,r9 1c: 42 00 ff f8 bdnz 14 <f+0x14> 20: 4e 80 00 20 blr