<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/138465>138465</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Optimization pass to improve performance of interpreters, and other recursive programs
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          the-ssd
      </td>
    </tr>
</table>

<pre>
    Currently, LLVM generates an additional jump for interpreters, which could be inclined for better performance. (which is how interpreters written in Assembly like LuaJIT's interpreter work).

Example:
```llvm
define i32 @example() {
dispatch:
   ; dispatch logic
   br {instruction}
instruction1:
   ; instruction logic
 br label %dispatch
instruction2:
   ; instruction logic
  br label %dispatch
}
```
But a faster version inlines logic from dispatch into instructions, and usually runs faster.
```llvm
define i32 @example() {
 ; dispatch logic
   br {instruction}
instruction1:
   ; instruction logic
   ; dispatch logic
   br {instruction}
instruction2:
   ; instruction logic
   ; dispatch logic
   br {instruction}
}
```
But this is also a small optimization for a small amount of programs, and maybe better suited for a plugin.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJy0VE1v2zgQ_TXUZRBBor7sgw52sgZ2kcVeFr1T1EhiQpECh7Tr_vqCspM4RYt-oYABQ5x5b8j3ZkYQqdEgtqzas-ohEcFP1rV-wjuiPulsf27vg3NovD4zfg-Pjx_-hRENOuGRQBgQfa-8skZoeArzAoN1oIxHtzj06CiiTpOSE0gbdA8dgjJSK4P9mtuh9-hgQTdYNwsjMQXGNxeIIpjs6R0fnJzyHg0oAzsinDt9Bq2eER6D-Ofv_xlv6BYAJ-ueGd-mLNuxbPfXRzEvGlkRP1idXX5aH2eW7XoclEFQBQdWZnhN5RvGt8CafcxQtAgvpwseAFixh5dD0HZU8nLeuYhQhrwLMurDmgeW7W4O8nccN4E3ms6BFh1qYLx6rfyOhH-f5Fsslwu9SsCy3T54EDAIirId0VHkUSZ6RRc-GJyd396rjLe3RVezhekhUBBan8EFQ1fC9Jf0_rP6_o59P6L8z9J_3RI_KYqTIDRZEECz0Brs4tWsPom1Ypyjl4CYbTAe7ACLs6MT86spszh3-DJvFJS_TqCARYdRmTTp26LfFluRYJs3ZV1syirPk6ktZCZ5XxV5va15XnSD4FjUfCOqupS8xES1PONVVmVlvik3RZ4O21zWdVNnvcSm4U20dxZKp9H51LoxUUQB27zYlHWVrP1J6xbi3OAJ1ijjPC4l10bQXRdGYmWmFXl6o_HKa2z_u1VjEUQQG3NenD3i7WqJsny5nKI01k_owKEMjlSEXKVLgtPt5P1C0W1-YPwwKj-FLpV2Zvyw9vHl725x9gmlZ_ywXp4YP1xfd2z55wAAAP__RXrF_w">