avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [avr-gcc-list] optimizer


From: Ben Mann
Subject: RE: [avr-gcc-list] optimizer
Date: Wed, 24 Nov 2004 20:14:03 +0800

I have noticed this sort of "optimisation" elsewhere too.

In my case it was fairly benign and I didn't care, but I was surprised to
see it reuse another register which had been set to zero rather than use the
__zero_reg__, which would seem to have made everything a little more
consistent.

ie, my code was something like

if (!foo) {
        bar = 0;        
}

The assembler sets bar to the register holding the stored value of foo, not
__zero_reg__

I'd also be interested to see if someone has a solution for this.

Ben Mann
mailto:address@hidden


-----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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]