Hello,
when I compile(avr-gcc -c -Os -mmcu=atmega8 test.c) this code:
int main (void)
{
while (((*(volatile unsigned char *)((0x0B) + 0x20)) & (1<<5)) == 0) {
;
}
return (0);
}
with gcc 3.3.1 I get this asm loop:
8: 5d 9b sbis 0x0b, 5 ; 11
a: fe cf rjmp .-4 ; 0x8
with gcc 3.4.2 or 4.0.0 I get this:
8: 41 e0 ldi r20, 0x01 ; 1
a: 50 e0 ldi r21, 0x00 ; 0
c: 8b b1 in r24, 0x0b ; 11
e: 99 27 eor r25, r25
10: 25 e0 ldi r18, 0x05 ; 5
12: 96 95 lsr r25
14: 87 95 ror r24
16: 2a 95 dec r18
18: e1 f7 brne .-8 ; 0x12
1a: 84 27 eor r24, r20
1c: 95 27 eor r25, r21
1e: 9c 01 movw r18, r24
20: 21 70 andi r18, 0x01 ; 1
22: 30 70 andi r19, 0x00 ; 0
24: 80 fd sbrc r24, 0
26: f2 cf rjmp .-28 ; 0xc
--
Summary: [3.4/4.0 Regression] 'while' loop performace regression
on avr target
Product: gcc
Version: 3.4.3
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: target
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: berndtrog at yahoo dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: avr-elf
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18002