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]

Half-baked i386 stack alignment thoughts


Given:

  int
  func(int a, int b, int c)
    {
    int d;

    d = 0;
    if (a)
      d += subr(a, a);
    if (b)
      d += subr(b, b);
    d += subr(c, c);
    return d;
    }

produces:

  -O2                   -O2 -maccumulate-outgoing-args

  ...                   ...
  subl    $8, %esp 
  pushl   %eax          movl    %eax, (%esp)
  pushl   %eax          movl    %eax, 4(%esp)
  call    subr          call    subr
  movl    %eax, %ebx    movl    %eax, %ebx
  addl    $16, %esp
  ...                   ...


The default code generation suffers from too many stack adjustments.
-maccumulate-outgoing-args solves that problem, however it suffers
from using a more expensive addressing mode.

What I propose is making -maccumulate-outgoing-args the default
and use push to place the arguments on the stack.  I.e.:

  ...
  addl    $8, %esp
  pushl   %eax
  pushl   %eax
  call    subr
  movl    %eax, %ebx
  ...

Questions, comments, and suggestions welcomed.

-- John
-------------------------------------------------------------------------
|   Feith Systems  |   Voice: 1-215-646-8000  |  Email: john@feith.com  |
|    John Wehle    |     Fax: 1-215-540-5495  |                         |
-------------------------------------------------------------------------


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