At "-Os", the two "popl %ebp" instructions
in the alternate branches could have been collapsed.

$ cat tailcall.c 
void foo(int a)
{
  if (a)
    bar();
  else
    baz();
}
$ gcc -Os -S tailcall.c 
$ cat tailcall.s 
        .file   "tailcall.c"
        .text
.globl foo
        .type   foo, @function
foo:
        pushl   %ebp
        movl    %esp, %ebp
        cmpl    $0, 8(%ebp)
        je      .L2
        popl    %ebp
        jmp     bar
.L2:
        popl    %ebp
        jmp     baz
        .size   foo, .-foo
        .ident  "GCC: (GNU) 4.4.0 20080330 (experimental)"
        .section        .note.GNU-stack,"",@progbits


-- 
           Summary: collapsing popping args for tail calls at -Os
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P3
         Component: rtl-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tkoenig at gcc dot gnu dot org


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

Reply via email to