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

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

Re: [avr-gcc-list] Bad optimization AVR-GCC 4.1.1 compared to AVR-GCC 3.


From: Tom Deutschman
Subject: Re: [avr-gcc-list] Bad optimization AVR-GCC 4.1.1 compared to AVR-GCC 3.4.6
Date: Fri, 6 Oct 2006 07:12:35 -0700

For your reference, here are links to PDFs of assembler listing and map file comparisons from your example source when compiled with avr-gcc 3.4.6 and 4.1.1 using your specified compiler options (plus those required to generate the assembly listing and map files.)

http://www.projectpoint.us/avr-gcc/compare-listings.pdf
http://www.projectpoint.us/avr-gcc/compare-maps.pdf

Does anyone know how to include high level source in assembly listings? I would have thought that the -Wa,-ahls compiler option to the assembler would do this, but it does not.

Tom

On 10/6/06, Peter Dannegger <address@hidden> wrote:
Dear GCC experts,

following an example code, which was about 25% bigger on using the
AVR-GCC 4.1.1. instead AVR-GCC 3.4.6.

The code was bigger on 3 points:

1.
From a 16 bit variable, where only the high byte was used, also the low
byte was read from SRAM into a register (3 words more).

2.
A function was inlined nevertheless, the optimization for size -Os was
forced and no inline or static attribute was given. It seems, that the
-Os switch was ignored.

3.
A fully crazy behaviour was seen on the attempt to clear a variable
conditional.
Instead clearing the register (1 word instruction ) like on the AVR-GCC
3.4.6, a big sequence of code (23 words) was duplicated.


Following the code, it was compiled with this command line:

avr-gcc.exe -xc -Os -mmcu=attiny26 -Wall -g disptime.c

int main(void)
{
  for(;;){

  }
}


unsigned int sec_timer;

unsigned char minute, hour;

unsigned char digit[4];

unsigned char numbers[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };


unsigned char get7s( unsigned char val )
{
  return numbers[val];
}


void display_time( unsigned char set )
{
  unsigned char t = sec_timer >> 8;     // high byte only

  if( t < 10 )                          // 1/2 second
    set = 0;

  if( set == 1 ){
    digit[3] = 0;
    digit[2] = 0;
  }else{
    digit[3] = get7s( hour / 10);
    digit[2] = get7s( hour % 10);
  }
  if( set == 2 ){
    digit[1] = 0;
    digit[0] = 0;
  }else{
    digit[1] = get7s( minute / 10);
    digit[0] = get7s( minute % 10);
  }
}

--
        mit freundlichen GrĂ¼ssen

        Peter Dannegger

        SPECS - COMPETENCE IN SURFACE SCIENCE
        -------------------------------------
        Peter Dannegger
        Specs GmbH
        Voltastr. 5
        13355 Berlin
        Germany
        phone +49 (30) 467 824-21
        fax   +49 (30) 464 20 83
         address@hidden
        www.specs.de






_______________________________________________
AVR-GCC-list mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list



--
--
Tom Deutschman
Wizbang Designs, Inc.
1217 S. Oak St.
Spokane, WA  99204
(509) 251-1106
reply via email to

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