http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56219
Bug #: 56219 Summary: avr-gcc-4.7.2 missing __uint24 loop optimisation Classification: Unclassified Product: gcc Version: 4.7.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassig...@gcc.gnu.org ReportedBy: demiurg_...@freemail.ru int main(void) { // static const unsigned long __flash br[8] = {0,}; // case1: 194 bytes static const __uint24 __flash br[8] = {0,}; // case2: 190 bytes (should be case1 minus 8 bytes) unsigned char i=0; for (;;i++) { *((volatile unsigned char*)100) = br[i%8]; } return (0); } //case1: avr-gcc-4.7.2 -S -mmcu=atmega8 -Os main.c ldi r24,0 .L2: mov r30,r24 andi r30,lo8(7) ldi r25,lo8(4) mul r30,r25 movw r30,r0 clr __zero_reg__ subi r30,lo8(-(br.1322)) sbci r31,hi8(-(br.1322)) lpm r25,Z sts 100,r25 subi r24,lo8(-(1)) rjmp .L2 //case2: avr-gcc-4.7.2 -S -mmcu=atmega8 -Os main.c ldi r18,0 .L2: mov r24,r18 andi r24,lo8(7) ldi r25,0 movw r30,r24 lsl r30 rol r31 add r30,r24 adc r31,r25 subi r30,lo8(-(br.1322)) sbci r31,hi8(-(br.1322)) lpm r24,Z sts 100,r24 subi r18,lo8(-(1)) rjmp .L2