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

            Bug ID: 60104
           Summary: load not folded into indirect branch on x86-64
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dan433584 at gmail dot com

Created attachment 32075
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32075&action=edit
a C testcase

The attached testcase is a greatly reduced interpreter loop, containing a
simple load and indirect branch:

  goto *addresses[*pc++]

gcc 4.8.2 (as well as older versions) with -O2 produces the following x86-64
output:

  movq    addresses.1721(,%rax,8), %rax
  jmp    *%rax

Since the loaded value is not used after the branch, there's no need to hold it
in a register, so the load could be folded into the branch. This would improve
code size and instruction count.

Reply via email to