[Top][All Lists]

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

Re: [avr-gcc-list] avr-libc deprecation/optimisation question

From: Neil Johnson
Subject: Re: [avr-gcc-list] avr-libc deprecation/optimisation question
Date: Sat, 11 Oct 2003 16:22:40 +0100 (BST)


> When I compile the following code:
>           PORTD = (1<<5);
> For this C instruction I get from avr-objdump this result:
> 28:   80 e2           ldi     r24, 0x20       ; 32
> 2a:   80 93 32 00     sts     0x0032, r24
> so the compiler chooses the sts instruction to load the data in the SRAM
>   mapping of the registers. This is of course perfectly acceptable.

I found this behaviour too when working on my ATmega8 project.  However,
with the compiler in "-Os" mode it generates the smaller and faster "out"

My guess is it something to do with the way that GCC separates the RTL
generator and the optimizer: I would hazard a guess the RTL generator
emits nodes to (a) evaluate the right side, returning the result in a
register, and (b) the left hand side then storing the register from the
right hand side into global memory.

Now, turning on the optimizer combines these two RTL nodes into a single
"out" instruction.  As you say, both cases are perfectly legal, but one is
certainly more preferable!


Neil Johnson :: Computer Laboratory :: University of Cambridge ::
http://www.njohnson.co.uk          http://www.cl.cam.ac.uk/~nej22
----  IEE Cambridge Branch: http://www.iee-cambridge.org.uk  ----

reply via email to

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