https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100962
--- Comment #3 from mojo at world3 dot net ---
Apologies, I noticed I had -Og on. Tried with -O3 and it optimised the struct
away. With -O2 it uses the Z register with displacement, reading data from
flash.
So it seems that only -Og produces poo
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100962
--- Comment #2 from mojo at world3 dot net ---
avr-gcc-11.1.0-x64-windows>bin\avr-gcc -Og -xc -Wall -mmcu=atxmega64a1u test.c
avr-gcc-11.1.0-x64-windows>bin\avr-objdump -h -S a.out > list.s
Still producing code like this
2de: 18 97
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100962
Bug ID: 100962
Summary: Poor optimization of AVR code when using structs in
__flash
Product: gcc
Version: 5.4.0
Status: UNCONFIRMED
Severity: normal