<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - X86: Tail calls with function pointer indirection not folded when more than 1 parameter is passed"
   href="https://bugs.llvm.org/show_bug.cgi?id=50042">50042</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>X86: Tail calls with function pointer indirection not folded when more than 1 parameter is passed
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Backend: X86
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>mejedi@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>craig.topper@gmail.com, llvm-bugs@lists.llvm.org, llvm-dev@redking.me.uk, pengfei.wang@intel.com, spatel+llvm@rotateright.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=24774" name="attach_24774" title="reproducer">attachment 24774</a> <a href="attachment.cgi?id=24774&action=edit" title="reproducer">[details]</a></span>
reproducer

The following snippet produces the assembly with function pointer table
indexing folded into JMP:


typedef void (*FnTy3) (void *);

void dispatch15(FnTy3 *tab, intptr_t i) {
  tab[i](tab);
}


_dispatch15:                            ## @dispatch15
## %bb.0:                               ## %entry
        jmpq    *(%rdi,%rsi,8)                  ## TAILCALL


If the called function takes at least 2 parameters, indexing isn't folded.


typedef void (*FnTy2) (void *, intptr_t);

void dispatch1(FnTy2 *tab, intptr_t i) {
  tab[i](tab, i);
}


_dispatch1:                             ## @dispatch1
## %bb.0:                               ## %entry
        movq    (%rdi,%rsi,8), %rax
        jmpq    *%rax                           ## TAILCALL</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>