Skip to content

Optimization pass to improve performance of interpreters, and other recursive programs #138465

Open
@the-ssd

Description

@the-ssd

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:

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.

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions