[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-gcc-list] Small frame optimization: Butterfly -= 90 bytes
From: |
Dmitry K. |
Subject: |
[avr-gcc-list] Small frame optimization: Butterfly -= 90 bytes |
Date: |
Mon, 19 Jan 2004 08:33:41 +1000 |
User-agent: |
KMail/1.5 |
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.
- [avr-gcc-list] Small frame optimization: Butterfly -= 90 bytes,
Dmitry K. <=