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

            Bug ID: 87565
           Summary: suboptimal memory-indirect tailcalls on arm
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: amonakov at gcc dot gnu.org
  Target Milestone: ---
            Target: arm-*-*

When tailcalling via a pointer that needs to be loaded from memory, gcc could
use 'ldr pc, [...]' instead of an ldr-bx sequence.

void foo(int a, int b, void (*p[])(int, int))
{
    p[1](a, b);
}

I see at -Os

foo:
        ldr     r3, [r2, #4]
        bx      r3  @ indirect register sibling call

But afaict this could be simply

foo:
        ldr     pc, [r2, #4]

(x86 has memory-indirect jumps too and there GCC gets this right via dedicated
sibcall patterns)

Reply via email to