This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: avr compilation


This may related with subreg regmove finding
Suggest specifiy -fdump-rtl-regmove to see what happen after this pass
Maybe avr need a target dependent regmove pass to handle this


Best, Jiong

On 03/18/2011 04:47 PM, Paulo J. Matos wrote:
Hi all,

I am looking at the avr backend in order to try to sort some things out on my own backend.

One of the tests I am doing is by compiling the following:
int x = 0x1010;
int y = 0x0101;

int add(void)
{
  return x+y;
}

It compiles to (in gcc-4.3.5_avr with -Os)
add:
/* prologue: function */
/* frame size = 0 */
        lds r18,y
        lds r19,(y)+1
        lds r24,x
        lds r25,(x)+1
        add r18,r24
        adc r19,r25
        mov r24,r18
        mov r25,r19
/* epilogue start */
        ret

I don't know much avr assembler so bear with me but I would expect this to be written:
add:
/* prologue: function */
/* frame size = 0 */
lds r18,y
lds r19,(y)+1
lds r24,x
lds r25,(x)+1
add r24,r18
adc r25,r19
/* epilogue start */
ret


By inverting the add arguments we save two mov instructions.

If it can be written like this any ideas on why GCC is avoiding it?

Cheers,

--
PMatos



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]