Hi all,

        I have spending my time optimizing the source code for my project and I 
noticed that something could be better. Look at this example :

#include <io.h>

int f2(int y) {
        return ++y;
}

void f1(int x) {
        ++x;
        return f2(x);
}

main() {
        f1(10);
}

        Compilling it with the options "-mmcu=msp430x435 -O2 -Wall -ggdb3 
-mendup-at=main -pipe" results on this .lst file :

--- cut ---
int f2(int y) {
    return ++y;
    c040:       1f 53           inc     r15             ;
}
    c042:       30 41           ret

0000c044 <f1>:

int f1(int x) {
    ++x;
    c044:       1f 53           inc     r15             ;
    return f2(x);
    c046:       b0 12 40 c0     call    #-16320 ;#0xc040
}
    c04a:       30 41           ret
--- cut ---


        The problem is the last "call" and "ret" instructions could turn into 
one 
branch instruction. It could save some cycles and one stack position. I think 
it will not be a great optimization but....


Marcos

Reply via email to