[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [avr-chat] Missed Optimisation ?
From: |
Boyapati, Anitha |
Subject: |
RE: [avr-chat] Missed Optimisation ? |
Date: |
Wed, 2 Mar 2011 16:38:25 +0800 |
>-----Original Message-----
>From: address@hidden [mailto:avr-
>address@hidden On Behalf Of Pertti
>Kellomäki
>Sent: Wednesday, March 02, 2011 1:08 PM
>To: address@hidden
>Subject: Re: [avr-chat] Missed Optimisation ?
>
>Like Colin said, the C standard defines the semantics of the language
>in terms of an abstract machine. Normally the compiler is allowed to
>use an "as if" approximation of the semantics and leave out things
>that would not change the state of the abstract machine.
>
>One way to look at volatile is that it is a way to tell the compiler
>that you know things that the compiler does not know, and therefore
>the compiler needs to do things "by the book", i.e. do all the things
>that the abstract machine semantics requires it to do.
>
>I don't have an AVR compiler handy, but it would be instructive to see
>what the compiler generates for "result = result*0" where result is
>volatile.
result =result * 0;
00000058 LDD R24,Y+1 Load indirect with displacement
00000059 LDD R25,Y+2 Load indirect with displacement
0000005A LDD R26,Y+3 Load indirect with displacement
0000005B LDD R27,Y+4 Load indirect with displacement
0000005C STD Y+1,R1 Store indirect with displacement
0000005D STD Y+2,R1 Store indirect with displacement
0000005E STD Y+3,R1 Store indirect with displacement
0000005F STD Y+4,R1 Store indirect with displacement
Code generated with -O2 turned on. R1 is zero register. The compiler expects
the value of 'result' to be 0 which I think is ok no matter what 'result' is
during the assignment execution.
Likewise:
result =result * 1;
00000058 LDD R24,Y+1 Load indirect with displacement
00000059 LDD R25,Y+2 Load indirect with displacement
0000005A LDD R26,Y+3 Load indirect with displacement
0000005B LDD R27,Y+4 Load indirect with displacement
0000005C STD Y+1,R24 Store indirect with displacement
0000005D STD Y+2,R25 Store indirect with displacement
0000005E STD Y+3,R26 Store indirect with displacement
0000005F STD Y+4,R27 Store indirect with displacement
Anitha
- RE: [avr-chat] Missed Optimisation ?, (continued)
- Re: [avr-chat] Missed Optimisation ?, Graham Davies, 2011/03/01
- Re: [avr-chat] Missed Optimisation ?, Michael Hennebry, 2011/03/01
- Re: [avr-chat] Missed Optimisation ?, Michael Hennebry, 2011/03/02
- Re: [avr-chat] Missed Optimisation ?, Alex Eremeenkov, 2011/03/02
- Re: [avr-chat] Missed Optimisation ?, Michael Hennebry, 2011/03/02
- Re: [avr-chat] Missed Optimisation ?, Alex Eremeenkov, 2011/03/02
- Re: [avr-chat] Missed Optimisation ?, Michael Hennebry, 2011/03/03
- Message not available
- Re: [avr-chat] Missed Optimisation ?, Michael Hennebry, 2011/03/03
- Re: [avr-chat] Missed Optimisation ?, Pertti Kellomäki, 2011/03/04
- Re: [avr-chat] Missed Optimisation ?, Graham Davies, 2011/03/04
- Re: [avr-chat] Missed Optimisation ?, Michael Hennebry, 2011/03/05
- Re: [avr-chat] Missed Optimisation ?, Graham Davies, 2011/03/05