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]

will gcc support better stack space reuse?


Hi,

Was wondering whether a new version of GCC for x86 (linux) can now
reallocate unused stack space from locals defined in different scopes.
E.g., functions suck1 and suck2 suffer from increased stack pressure because
gcc (in my case 3.3.3 on linux/x86) cannot smartly reuse the stack space.
Anyone out there with insight on why this is the case and when gcc might
handle stack packing (if not already).

int garray[64];
static inline numberone(int a, int b){
        int array[64];
        array[1]=a*b;
        garray[0]=array[1];
}

static inline numbertwo(int a, int b){
        int array[64];
        array[1]=a*b;
        garray[1]=array[1];
}

void suck1(int a, int b){
        numberone(a,b);
        numbertwo(a,b);
}

void suck2(int a, int b){
        {
        int array[64];
        array[1]=a*b;
        garray[0]=array[1];
        }
        {
        int array[64];
        array[1]=a*b;
        garray[1]=array[1];
        }
}

Marc


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