public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/14151] New: new-ra get frame size incorrect
@ 2004-02-15 18:37 andrewhutchinson at cox dot net
  2004-02-15 18:45 ` [Bug optimization/14151] [new-ra] " pinskia at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: andrewhutchinson at cox dot net @ 2004-02-15 18:37 UTC (permalink / raw)
  To: gcc-bugs

new-ra gives substantial code size and speed improvments on avr target.
However, gain is lost because the frame size is wrong. Or more precisely the
frame size reflects the inclusion of stack slots that have been optimised away.

Code below show a simple case where frame size is 2 - presumably reflecting the
"i" local variable that is in a register.

Without -fnew-ra, the epilog/prolog is empty (ie frame pointer can be eliminated)

I have managed to determine that the AVR target is being told that the frame
size is 2.

int CallbackFunc[10];
void Timer0_Init(void)
{
    //mt char i;
	char i;

    // Initialize array of callback functions
    for (i=0; i<10; i++)
        CallbackFunc[i] = 0;

}





compiler options (GCC 3.3.1 target AVR). Host win2k and XP

-Os -W -Wall -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums  


WITHOUT -new-ra we get no frame (since it get optimized away)

    .file   "testcase.c"
    .arch avr2
__SREG__ = 0x3f
__SP_H__ = 0x3e
__SP_L__ = 0x3d
__tmp_reg__ = 0
__zero_reg__ = 1
    .global __do_copy_data
    .global __do_clear_bss
    .text
.global Timer0_Init
    .type   Timer0_Init, @function
Timer0_Init:
/* prologue: frame size=0 */
/* prologue end (size=0) */
    ldi r24,lo8(0)
    ldi r30,lo8(CallbackFunc)
    ldi r31,hi8(CallbackFunc)
.L6:
    st Z+,__zero_reg__
    st Z+,__zero_reg__
    subi r24,lo8(-(1))
    cpi r24,lo8(10)
    brlo .L6
/* epilogue: frame size=0 */
    ret
/* epilogue end (size=1) */
/* function Timer0_Init size 9 (8) */
    .size   Timer0_Init, .-Timer0_Init
    .comm CallbackFunc,20,1
/* File "testcase.c": code    9 = 0x0009 (   8), prologues   0, epilogues   1 */


NOW WITH -new-ra we get:
========================

    .file   "testcase.c"
    .arch avr2
__SREG__ = 0x3f
__SP_H__ = 0x3e
__SP_L__ = 0x3d
__tmp_reg__ = 0
__zero_reg__ = 1
    .global __do_copy_data
    .global __do_clear_bss
    .text
.global Timer0_Init
    .type   Timer0_Init, @function
Timer0_Init:
/* 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) */
    ldi r24,lo8(0)
    ldi r30,lo8(CallbackFunc)
    ldi r31,hi8(CallbackFunc)
.L6:
    st Z+,__zero_reg__
    st Z+,__zero_reg__
    subi r24,lo8(-(1))
    cpi r24,lo8(10)
    brlo .L6
/* 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) */
/* function Timer0_Init size 27 (8) */
    .size   Timer0_Init, .-Timer0_Init
    .comm CallbackFunc,20,1
/* File "testcase.c": code   27 = 0x001b (   8), prologues  10, epilogues   9 */



__________________________________________________________________

-- 
           Summary: new-ra get frame size incorrect
           Product: gcc
           Version: new-ra
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: andrewhutchinson at cox dot net
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: 3.3.1
GCC target triplet: avr


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14151


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2005-01-17 15:25 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-02-15 18:37 [Bug c/14151] New: new-ra get frame size incorrect andrewhutchinson at cox dot net
2004-02-15 18:45 ` [Bug optimization/14151] [new-ra] " pinskia at gcc dot gnu dot org
2004-02-15 18:46 ` pinskia at gcc dot gnu dot org
2004-04-08 21:03 ` 1319 at bot dot ru
2004-08-12  1:51 ` [Bug rtl-optimization/14151] " pinskia at gcc dot gnu dot org
2004-12-25  2:34 ` andrewhutchinson at cox dot net
2004-12-25 10:21 ` steven at gcc dot gnu dot org
2005-01-17 15:25 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).