This is the mail archive of the gcc-help@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]

help?


gcc-help-help,hi!

I am using gcc-2.95.3 form ARM.

i have a c program file as follow: 

void foo1 ()
{
  int j[]={1,2};
}

void foo2 ()
{
  int j[]={1,2,3};
}


but the code generated for foo1 are:
foo1:
        @ args = 0, pretend = 0, frame = 8
        @ frame_needed = 1, current_function_anonymous_args = 0
        mov     ip, sp
        stmfd   sp!, {r4, fp, ip, lr, pc}
        sub     fp, ip, #4
        sub     sp, sp, #8
        sub     r3, fp, #24
        ldr     r2, .L4
        ldmia   r2, {r3-r4}
        sub     r1, fp, #16
        stmdb   r1, {r3-r4}
        b       .L3

and the code generated for foo2 are:
foo2:
        @ args = 0, pretend = 0, frame = 12
        @ frame_needed = 1, current_function_anonymous_args = 0
        mov     ip, sp
        stmfd   sp!, {fp, ip, lr, pc}
        sub     fp, ip, #4
        sub     sp, sp, #12
        sub     r3, fp, #24
        ldr     r2, .L8
        sub     r3, fp, #24		@**************************it is the redundant instruction, the same as above two.
        mov     ip, r2
        ldmia   ip, {r0-r2}     @ load multiple
        stmia   r3, {r0-r2}     @ str multiple
        b       .L7
  

my question is that in function foo2 there is a redundant instruction (sub     r3, fp, #24),
i donot think it's needed, whereas, there hasnot this instruction in function foo1.
why compiler generate it ?

thanks!

 				
              Shen Hui
              shenhui@mprc.pku.edu.cn
                 2003-07-12

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