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

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

[avr-gcc-list] Bad optimization AVR-GCC 4.1.1 compared to AVR-GCC 3.4.6


From: Peter Dannegger
Subject: [avr-gcc-list] Bad optimization AVR-GCC 4.1.1 compared to AVR-GCC 3.4.6
Date: Fri, 06 Oct 2006 15:08:47 +0200
User-agent: Mozilla Thunderbird 1.0 (Windows/20041206)

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








reply via email to

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