[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [avr-gcc-list] Small frame optimization: Butterfly -= 90 bytes
From: |
HutchinsonAndy |
Subject: |
RE: [avr-gcc-list] Small frame optimization: Butterfly -= 90 bytes |
Date: |
Mon, 19 Jan 2004 10:20:59 -0500 |
Nice one!
I have been looking at the new register allocator. This produces much better
code in many cases BUT unfortunately it seems to have a bug that leaves space
on the stack - ie a frame pointer when one is not reqd.
Your change mitigates that effect.
"Dmitry K." <address@hidden> wrote:
>Hi all.
>
>Avr-gcc use list of pop's to restore stack in body of function.
>(After call with parameters in stack, small size).
>The same can be made for prologues and epilogues.
>It has reduced the size of code Butterfly by 90 bytes (with
>a simultaneous prize in speed).
>
>See example:
>
> extern void foo (char *);
> void foo_2 (void)
> {
> char s[2];
> foo(s);
> }
>
>Original (3.3.2) compilation:
>
> foo_2:
> /* prologue: frame size=2 */
> push r28
> push r29
> in r28,__SP_L__
> in r29,__SP_H__
> sbiw r28,2
> in __tmp_reg__,__SREG__
> cli
> out __SP_H__,r29
> out __SREG__,__tmp_reg__
> out __SP_L__,r28
> /* prologue end (size=10) */
> mov r24,r28
> mov r25,r29
> adiw r24,1
> rcall foo
> /* epilogue: frame size=2 */
> adiw r28,2
> in __tmp_reg__,__SREG__
> cli
> out __SP_H__,r29
> out __SREG__,__tmp_reg__
> out __SP_L__,r28
> pop r29
> pop r28
> ret
> /* epilogue end (size=9) */
>
>After optimization:
>
> foo_2:
> /* prologue: frame size=2 */
> push r28
> push r29
> rcall .
> in r28,__SP_L__
> in r29,__SP_H__
> /* prologue end (size=5) */
> mov r24,r28
> mov r25,r29
> adiw r24,1
> rcall foo
> /* epilogue: frame size=2 */
> pop __tmp_reg__
> pop __tmp_reg__
> pop r29
> pop r28
> ret
> /* epilogue end (size=5) */
>
>Patch for avr.c in attachment:
>----------------------------------------------------------------------
> FOR LOOCKING OF IDEA ONLY, NOT USE FOR WORK.
> THERE ARE IMPERFECTIONS AND MISTAKES ARE POSSIBLE, DID NOT TEST.
>----------------------------------------------------------------------
>
>Best wishes.
>
__________________________________________________________________
New! Unlimited Netscape Internet Service.
Only $9.95 a month -- Sign up today at http://isp.netscape.com/register
Act now to get a personalized email address!
Netscape. Just the Net You Need.