[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [avr-gcc-list] optimizer
From: |
Bernard Fouché |
Subject: |
RE: [avr-gcc-list] optimizer |
Date: |
Wed, 24 Nov 2004 15:12:35 +0100 |
As I written in my last post, I'm now using similar stuff. That will be a
maintenance pain and the code written is so gcc oriented that it becomes a
problem.
Bernard
-----Message d'origine-----
De : Ben Mann [mailto:address@hidden
Envoyé : mercredi 24 novembre 2004 15:03
À : 'Haase Bjoern (PT-BEU/MKP5) *'; 'Bernard Fouché';
address@hidden
Objet : RE: [avr-gcc-list] optimizer
I can understand there's some challenge of making these sort of changes to
the RTL compiler. Nevertheless it seems that for embedded work this sort of
stuff is going to be quite important (speed and size always an issue...)
I realise this is not very helpful, but the best I could dream up so far was
a little macro to replace the compiler's casting:
//optimally cast a char to a long
#define CAST_CHAR2LONG(dest,src) \
*((char*)&(dest)) = (src); \
*((char*)&(dest)+1) = 0; \
*((char*)&(dest)+2) = 0; \
*((char*)&(dest)+3) = 0
long var;
...
CAST_CHAR2LONG(var,eeprom_read_byte((char *)ADDR));
//replaces var = eeprom_read_byte((char *)ADDR)
The code generated is (as you might imagine) substantially tighter and works
for local or global "var". However, the syntax sucks. I wonder if there's a
better way?
Ben Mann
-----Original Message-----
From: Haase Bjoern (PT-BEU/MKP5) * [mailto:address@hidden
Sent: Wednesday, 24 November 2004 8:56 PM
To: address@hidden; Bernard Fouché; address@hidden
Subject: AW: [avr-gcc-list] optimizer
Hi,
--snip!--
IMHO the possible benefit of a 32-> 4x8 splitting at the RTL level does not
really justify
the required amount of changes in the compiler.
Björn
-----Original Message-----
From: address@hidden [mailto:address@hidden
On Behalf Of Bernard Fouché
Sent: Wednesday, 24 November 2004 7:18 PM
To: address@hidden
Subject: [avr-gcc-list] optimizer
Hi.
I'm compiling with -Os for atmega64 with avr-gcc 3.4.2. When I have
uint32_t var;
var=(uint32_t)function_returning_an_int8_t();
the generated code is, for instance:
var=(uint32_t)eeprom_read_byte((uint8_t *)EEPROM_PARM);
ldi r24, 0x36 ; 54
ldi r25, 0x00 ; 0
call 0xf9c0
eor r25, r25
eor r26, r26
eor r27, r27
sts 0x046B, r24
sts 0x046C, r25
sts 0x046D, r26
sts 0x046E, r27
Could it be instead:
ldi r24, 0x36 ; 54
ldi r25, 0x00 ; 0
call 0xf9c0
sts 0x046B, r24
sts 0x046C, r1
sts 0x046D, r1
sts 0x046E, r1
That would spare 6 bytes...
Bernard
_______________________________________________
avr-gcc-list mailing list
address@hidden http://www.avr1.org/mailman/listinfo/avr-gcc-list
_______________________________________________
avr-gcc-list mailing list
address@hidden http://www.avr1.org/mailman/listinfo/avr-gcc-list