Hi Bob, I can't fully tell what's going on with just the asm snippets you provide.
If you think that this is a GCC bug, then please fill out a GCC bug report. Thanks for checking the known bug list first. :-) If you fill in a GCC bug report, feel free to put my email address on the CC list of the bug report. Thanks, Eric Weddington > -----Original Message----- > From: > [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] > org] On Behalf Of Bob Paddock > Sent: Monday, February 19, 2007 2:49 PM > To: avr-gcc-list@nongnu.org > Subject: [avr-gcc-list] Wrong excution order in 4.1.1, but > not 3.4.5,regression? > > > I'm seeing something in 4.1.1 that is not making > sense. The code produced is clearly the wrong > order, in 4.1.1. Code from 3.4.5 is the correct order. > > Optimization in both cases is set for -Os; > I'm using the same source code/Makfile and > pointing at different versions of WINAVR, > between 4.1.1 and 3.4.5. > > I've looked at the known problem list, but > I could not related this to any of those. > http://www.nongnu.org/avr-libc/bugs.html > > I can't seem to get a good cut down example > that produces the error. The code > effectively looks like this: > > static volatile PGM_UP pattern_flash_ptr_u8_v; /* IRQ > updates PORTB */ > static volatile PGM_UP pattern_flash_ptr_reload_u8_v; > [PGM_UP is unsigned version of PGM_P.] > > do{ > pattern_flash_ptr_u8_v = > pattern_flash_ptr_reload_u8_v = (PGM_UP) > pgm_read_word( &pattern_table[ 0 ] ); > }while( mode_button_press_count_u8 < max_button_presses_u8 ); > > In the real code 'mode_button_press_count_u8' actually could > change its value inside of the do{}while(), > and the pattern_table[ 0 ] index would > be a variable. I made these changes to the real code, > and the problem persists. > > For: > > pattern_flash_ptr_u8_v = pattern_flash_ptr_reload_u8_v = (PGM_UP) > pgm_read_word( &pattern_table[ 0 ] ); > > 4.1.1 produces: > > 3ca: e6 e8 ldi r30, 0x86 ; 134 > [Address of pattern_table] > 3cc: f0 e0 ldi r31, 0x00 ; 0 > 3ce: c8 95 lpm > 3d0: c0 2d mov r28, r0 > 3d2: 31 96 adiw r30, 0x01 ; 1 > 3d4: c8 95 lpm > 3d6: d0 2d mov r29, r0 > 3d8: 0c 2f mov r16, r28 [Missed > optimization, but that is > separate matter for an other time. r16/r17 was loaded above > only to be > overwritten here, and not needed below.] > 3da: 1d 2f mov r17, r29 > 3dc: ff 20 and r15, r15 > 3de: c9 f6 brne .-78 ; 0x392 > <main+0x74> [Jump to do{] > 3e0: 10 93 7b 00 sts 0x007B, r17 [This is > outside of the do{}while() so > the code fails.] > 3e4: 00 93 7a 00 sts 0x007A, r16 > 3e8: d0 93 7d 00 sts 0x007D, r29 > 3ec: c0 93 7c 00 sts 0x007C, r28 > > > 3.4.5 produces this, correct code: > > pattern_flash_ptr_u8_v = > pattern_flash_ptr_reload_u8_v = > (PGM_UP) pgm_read_word( &pattern_table[ 0 ] ); > 3ec: ef e3 ldi r30, 0x3F ; 63 > [Address of pattern_table] > 3ee: f0 e0 ldi r31, 0x00 ; 0 > 3f0: c8 95 lpm > 3f2: 80 2d mov r24, r0 > 3f4: 31 96 adiw r30, 0x01 ; 1 > 3f6: c8 95 lpm > 3f8: 90 2d mov r25, r0 > 3fa: 90 93 80 00 sts 0x0080, r25 [This is > inside the do{}while(), code > works. Doesn't have optimization issues either.] > 3fe: 80 93 7f 00 sts 0x007F, r24 > 402: 90 93 7e 00 sts 0x007E, r25 > 406: 80 93 7d 00 sts 0x007D, r24 > } > > }while( mode_button_press_count_u8 < max_button_presses_u8 ); > 40a: 90 91 79 00 lds r25, 0x0079 > 40e: 80 91 60 00 lds r24, 0x0060 > 412: 98 17 cp r25, r24 > 414: 08 f4 brcc .+2 ; 0x418 > <main+0xdc> [Exit do{}while] > 416: c5 cf rjmp .-118 ; 0x3a2 > <main+0x66> [Jump to do{] > > > > > _______________________________________________ > AVR-GCC-list mailing list > AVR-GCC-list@nongnu.org > http://lists.nongnu.org/mailman/listinfo/avr-gcc-list > _______________________________________________ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list