https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91131
--- Comment #11 from Per Dalgas Jakobsen <pdj at knaldgas dot dk> --- (In reply to Richard Biener from comment #10) > (In reply to Per Dalgas Jakobsen from comment #9) > > avr-gcc -O3 (and -Os, -O1, -O2): > > sts 0x0064, r1 ; 0x800064 <Reg_A> > > ldi r24, 0x08 ; 8 > > sts 0x0065, r24 ; 0x800065 <Reg_B> > > lds r24, 0x0060 ; 0x800060 <__data_start> > > sts 0x0063, r24 ; 0x800063 <Reg_C> > > sts 0x0066, r1 ; 0x800066 <Reg_D> > > ldi r24, 0xFF ; 255 > > sts 0x0062, r24 ; 0x800062 <__data_end> > > > > Nice improvement, but Reg_C is still loading from memory. Is it possible to > > get that into an immediate as well? > > No idea - that's a question for the architecture maintainers. It might > be that not all constants can be in the immediate. The LDI instruction can hold a full 8-bit immediate, although only for the registers r16-r31. r24 can use LDI, so it should not be an architecture thing. I tried to fiddle with the fields assignments, and setting more than one field causes it to store the result in memory instead of as immediate. > Note that RTL needs to get rid of the temporary since we expand from > ... > here we're too conservative in optimizing the volatile > aggregate copies (only their LHS is volatile). But we only have > the quite late store-merging pass merging the invididual bitfield > accesses (but I can see VN doing that as well). Unfortunately I'm out of my league here... > Yeah, most importantly the actual Rec_* are just stored to once so > correctness-wise -O0 is fine. Agreed.