[Top][All Lists]

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

Re: [avr-gcc-list] Pointer register allocation optimizer

From: Georg-Johann Lay
Subject: Re: [avr-gcc-list] Pointer register allocation optimizer
Date: Fri, 27 Jul 2012 20:44:15 +0200
User-agent: Thunderbird (Windows/20100228)

Wouter van Gulik schrieb:
Georg-Johann Lay schreef op 2012-07-27 16:06:
Wouter van Gulik schrieb:
Hi list,
This code:
char* f(char* p)
  return p;
Results in:

    mov r18,r24
    mov r19,r25
    subi r18,lo8(-(1))
    sbci r19,hi8(-(1))
    mov r24,r18
    mov r25,r19
When compiling with avr-gcc -O[23s] -mmcu=avr5 -S main.c

Oops, copy paste error; for avr5 movw is used to move the pointer registers. Still it does a useless move.

Looks very much like PR52278, which is still open.

I think this is the same, for sanity I also checked with int and long (against my Ubuntu gcc-avr 4.5.3) and it yields the same result; first move the register then the add, then move it back.

What I wonder: why is r18 picked? Clearly r26, or r30 are way better choices. Maybe this is fixed in 4.7.1 already, don't have a 4.7+ at the moment.

According to Vladimir, the register allocator (RA) should work smooth
with SUBREGs, but obviously, it does not.


You can try -fno-split-wide-types, but that might have other disadvantages.

That gives the expected result.



FYI, there is also the following post in gcc@ ML that
addresses exactly that artifact:



reply via email to

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