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

            Bug ID: 123735
           Summary: x86: switch + tailcall generates unnecessary jump
           Product: gcc
           Version: 15.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hpa at zytor dot com
  Target Milestone: ---

Created attachment 63432
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=63432&action=edit
Test case with output from gcc 15.2.1 and clang 21.1.8

The Linux kernel are these days generally compiled with -fno-jump-tables due to
indirect branch prediction concerns. This means that there are some large and
very performance-sensitive switch trees in Linux; the most critical one being
the system call dispatch. In that tree, the switch contains about 500 entries,
each of which tailcalls another function with a uniform prototype.

Unfortunately, gcc 15.2.1 generates unnecessary jcc-to-jmp for each case, which
at the very best means additional icache pressure. In contrast, clang 21.1.8
does not.

I have attached a simple test case as well as the .i, .s and .o output from gcc
and clang.

Reply via email to