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

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

Re: [avr-gcc-list] compiler improvments


From: Dmitry K.
Subject: Re: [avr-gcc-list] compiler improvments
Date: Mon, 5 Jan 2004 17:43:43 +1000
User-agent: KMail/1.5

HutchinsonAndy wrote:

> I am looking at improving the code that winavr(GCC-avr) produces.
> So far I have identified several areas where the current gcc machine model
> is less that perfect. In most cases I have working code that addresses the
> issue (not heavily tested though!)
>
> What I need is a peice of code to act as test/benchmark to see what saving
> are realisable. Currently I think that I am hitting around 15% mark but the
> code I have to test is not really enough.
>
> Any suggestions?
>

Not real, but very funny example:

Program:

   typedef struct { long lo; int in; } lo_in;
   lo_in foo (void)
   {
       lo_in x;
       x.lo = 1;
       x.in = 2;
       return x;
   }

Compiler:
   avr-gcc (GCC) 3.3.2

Diverses optimization levels (size in words) produce:

   -O0:     code   75 = 0x004b (  40), prologues  18, epilogues  17  (best !)
   -O1/2/s: code   80 = 0x0050 (  29), prologues  26, epilogues  25
   -O3:     code   79 = 0x004f (  28), prologues  26, epilogues  25
   Clocks for "-O3" (see foo-3.s.clocks):  132.

Manualy:
   foo:
        ldi     r18,lo8(1)      ; 1 clock
        ldi     r19,hi8(1)      ; 1
        ldi     r20,hlo8(1)     ; 1
        ldi     r21,hhi8(1)     ; 1
        ldi     r22,lo8(2)      ; 1
        ldi     r23,hi8(2)      ; 1
        ret                     ; 4
   /* code size: 7, clocks: 10   */

Sources and compiler results in attachment.

reply via email to

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