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

i386 stack slot optimisation


How does the i386 backend optimise the stack slot assignment to minimize
the displacement offset?

What code should I look at?

Or is there some other optimisation at work here...?

I.e.:

; -O0 => large offset
        leal    8268(%esp), %eax
        incl    (%eax)

; -O3 => small offset
        incl    40(%esp)



The source for a test case + the output are attached

gcc-4.0 -S stackframe.c -fomit-frame-pointer -O0 -o stackframe-O0.s
gcc-4.0 -S stackframe.c -fomit-frame-pointer -O3 -o stackframe-O3.s


This thread has a stack slot assignment optimisation patch that has
never been committed to GCC CVS, but the above indicats that there is
some sort of mechanism in GCC already to mitigate this problem...

http://gcc.gnu.org/ml/gcc-patches/2003-01/msg00019.html




-- 
Øyvind Harboe
http://www.zylin.com
int bar(int a);
int test1(int *);

int foo(int a, int b, int c, int d)
{
  int abc[1024];
  int j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z;
  int def[1024];
  for (j=0; j<bar(j); j++)
    {
      test1(abc);
  for (k=0; k<bar(k); k++)
    {
  for (l=0; l<bar(l); l++)
    {
  for (m=0; m<bar(m); m++)
    {
      test1(def);
  for (m=0; n<bar(n); n++)
    {
  for (o=0; o<bar(o); o++)
    {
  for (p=0; p<bar(p); p++)
    {
  for (r=0; r<bar(r); r++)
    {
  for (s=0; s<bar(s); s++)
    {
  for (t=0; t<bar(t); t++)
    {
  for (u=0; u<bar(u); u++)
    {
  for (v=0; v<bar(v); v++)
    {
  for (w=0; w<bar(w); w++)
    {
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
}

Attachment: stackframe-O0.s
Description: Text document

Attachment: stackframe-O3.s
Description: Text document


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