[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-gcc-list] WinAVR 20050214 (gcc 3.4.3) and optimizer bug.
From: |
Vesa Jääskeläinen |
Subject: |
[avr-gcc-list] WinAVR 20050214 (gcc 3.4.3) and optimizer bug. |
Date: |
Mon, 09 May 2005 00:26:45 +0300 |
User-agent: |
Mozilla Thunderbird (Windows/20050412) |
Hi,
I have been debugging why Ethernut brakes in certain situations with
gcc. And found an optimizer bug.
Here is smallest piece of code that I was able to reproduce it:
--- begin of code snippet ---
#define u_long unsigned long
#define u_char unsigned char
void test(int req, void *conf)
{
void **ppv = (void **) conf;
u_long *lvp = (u_long *) conf;
u_long lv = *lvp;
u_char bv = (u_char) lv;
switch (req) {
case 1:
if (bv)
{
asm ( "nop ; bv needs to be defined and used");
}
break;
case 2:
asm ( "nop ; entry to case 2");
if (ppv && (*ppv != 0)) {
asm ( "nop ; ppv and *ppv are not zeros");
} else {
asm ( "nop ; either ppv or *ppv is zero");
}
break;
}
}
--- end of code snippet ---
Now if we look at generated code here:
--- begin of assembly snippet ---
51 /* #APP */
52 001e 0000 nop ; entry to case 2
53 .LM9:
54 /* #NOAPP */
55 0020 8081 ld r24,Z
56 0022 9181 ldd r25,Z+1
57 0024 892B or r24,r25
58 0026 11F0 breq .L6
59 .LM10:
60 /* #APP */
61 0028 0000 nop ; ppv and *ppv are not zeros
62 /* #NOAPP */
63 002a 0895 ret
64 .L6:
65 .LM11:
66 /* #APP */
67 002c 0000 nop ; either ppv or *ppv is zero
68 /* #NOAPP */
69 .L1:
70 002e 0895 ret
--- end of assembly snippet ---
We can see that one compare is missing and this causes functional change
to code.
Could someone verify this bug and possibly fix it ;)
I used following command line:
avr-gcc -c -mmcu=atmega128 -Os -Wall -Wstrict-prototypes
-Wa,-ahlms=test.lst test.c -o test.o
Thanks,
Vesa Jääskeläinen
- [avr-gcc-list] WinAVR 20050214 (gcc 3.4.3) and optimizer bug.,
Vesa Jääskeläinen <=