https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61605

            Bug ID: 61605
           Summary: Potential optimization: Keep unclobbered argument
                    registers live across function calls
           Product: gcc
           Version: 4.10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: patrick at parcs dot ath.cx

If a function is known to not clobber an argument register then the caller
shouldn't have to save/reload that register across the function call.  Example:

The C code:

static int __attribute__ ((noinline))
bar (int x)
{
  return x + 3;
}

int
foo (int y)
{
  return y + bar (y);
}

generates:

bar:
.LFB0:
        .cfi_startproc
        leal    3(%rdi), %eax
        ret
        .cfi_endproc
foo:
.LFB1:
        .cfi_startproc
        movl    %edi, %edx
        call    bar
        addl    %edx, %eax
        ret
        .cfi_endproc

Here, %edi is saved to %edx even though the call to bar doesn't clobber %edi. 
The assembly for the function foo could potentially be:

        call    bar
        addl    %edi, %eax

Reply via email to