[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-gcc-list] Code size optimization
From: |
Antony MATRANGA |
Subject: |
[avr-gcc-list] Code size optimization |
Date: |
Mon, 10 Jan 2005 14:14:10 +0100 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.0; fr-FR; rv:1.7.3) Gecko/20040910 |
Hi, I've noticed something that i can't explain (logically)
The compiler is smart enough to insert RET instruction when it's usefull
but not enough when it's useless.
see:
void lcd_interf_RESET (BOOL Level)
{
if (Level)
1eac: 88 23 and r24, r24
1eae: 11 f0 breq .+4 ; 0x1eb4
{
PORTB |= _BV(PB1);
1eb0: 29 9a sbi 0x05, 1 ; 5
1eb2: 08 95 ret
}
else
{
PORTB &= ~_BV(PB1);
1eb4: 29 98 cbi 0x05, 1 ; 5
1eb6: 08 95 ret
1eb8: 08 95 ret
}
}
compiling on :
avr-gcc -gdwarf-2 -Wall -O2 -mmcu=atmega168 -fshort-enums -mtiny-stack -c -o
lcd_interf.o lcd_interf.c
In this case I think the last RET should be removed.
I a 8k application, i'm loosing 12 bytes. And one byte is one byte ... ;-)
Could someone tell me if there's a good reason not to optimize that ?
thank's
--
Antony
- [avr-gcc-list] Code size optimization,
Antony MATRANGA <=