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

            Bug ID: 106116
           Summary: Missed optimization: in no_reorder-attributed
                    functions, tail calls to the subsequent function could
                    just be function-to-function fallthrough
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pskocik at gmail dot com
  Target Milestone: ---

Example:

__attribute((noinline,no_reorder))
int fnWithExplicitArg(int ExplicitArg);

__attribute((noinline,no_reorder))
int fnWithDefaultArg(void){ return fnWithExplicitArg(42); }

int fnWithExplicitArg(int ExplicitArg){
    int useArg(int);
        return 12+useArg(ExplicitArg);
}

Generated fnWithDefaultArg:

fnWithDefaultArg:
        mov     edi, 42
        jmp     fnWithExplicitArg
fnWithExplicitArg:
        //...

Desired fnWithDefaultArg


fnWithDefaultArg:
        mov     edi, 42
        //fallthru
fnWithExplicitArg:
        //...

https://gcc.godbolt.org/z/Ph3onxoh9

Reply via email to