[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
AW: [avr-gcc-list] optimizer
From: |
Haase Bjoern (PT-BEU/MKP5) * |
Subject: |
AW: [avr-gcc-list] optimizer |
Date: |
Wed, 24 Nov 2004 13:55:36 +0100 |
Hi,
I have observed similar situations where the optimized generated code could be
realized
with much less registers: Mainly when dealing with global variables of more
than 8 bit
word length.
I also have been thinking about improving the compiler. I came
to the conclusion, that it is probably difficult to solve this problem:
The core problem seems to be that the compiler internally
considers r24:r25:r26:r27 to be one single logical
32 bit register r24. It seems that this logical 32 bit register is
broken down to 4x8 bit objects at the very last step only, i.e. when issuing the
assembler instructions.
In order to implement your suggested optimizations, it would probably be
necessary, to convert
all the 32 bit objects to 8 bit objects already at an earlier stage during the
compilation, i.e.
at the RTL level. This, however, probably would make it almost impossible to
generate object code
that could be used in a debugger. This might also prevent a lot of other useful
optimization steps
that require the variables to be considered as monolithic 32 bit quantities.
I have come to the conclusion, that the possible benefit of an early 32 bit ->
4x8 Bit
splitting also mainly affects code that uses global variables and does not help
much when
dealing with the more commonly present case that variables are held in
registers. Possibly your code
could be improved if you try to avoid global variables.
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
- AW: [avr-gcc-list] optimizer,
Haase Bjoern (PT-BEU/MKP5) * <=