https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83528
Bug ID: 83528 Summary: Nios2: redundant pointers to the record fields Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: already5chosen at yahoo dot com Target Milestone: --- Created attachment 42942 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=42942&action=edit eaxmple of bad code generation for Nios2 target In the loop over array of records Nios2 code generator accesses fields in the record through multiple pointers instead of single pointer. As a result of it, in my example each loop iteration updates 5 pointers instead of 1. In real world code I observed cases with even bigger amount of redundant pointers, sometimes so many that it causes spills of registers to the stack. gcc version 5.3.0 (Altera 17.1 Build 590) Yes, I know, gcc5 is no longer supported, but that's the latest version supplied by Altera/Intel which means that it's the latest version accessible by simple ned user like myself. system type: nios2-elf-gcc gcc options: -O2. -O1 is very similar. -O3 produces catastrophic code, but being a sane person I don't expect that -O3 on "minor" target would be usable. complete command line: nios2-elf-gcc -O2 -Wall -S foo.c the compiler output: no messages or warnings. Pay attention that nothing like that happens with MIPS32 target, which has exactly the same addressing modes as Nios2 and is nearly identical to Nios2 in most aspects. So, it seems to me that intermediate levels of gcc are not suspect. The problem is at the back end.