Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimizations #18

Open
jessiejs opened this issue May 22, 2024 · 0 comments
Open

Optimizations #18

jessiejs opened this issue May 22, 2024 · 0 comments

Comments

@jessiejs
Copy link

Analyze script and simplify the functions by applying the following transformations until they have no effect.

  1. Merge sum expressions (add and subtract)
  2. Merge shift expressions (ptr+ and ptr-)
  3. Static value analysis
    a. Go through the program and loops with a state which can either be an number or unknown
    b. Begin with a state of zero
    c. At the end of a loop/if, state is guranteed zero
    d. Sum expressions modify state
    e. Shift expressions destroy state, stopping optimization
    f. Body of loop has no defined state
    g. Replace sub expressions with static state, replace with set expressions
    h. If end of body of loop has static state of zero, then treat as if statement
    i. Inside of an if statement, inherit previous state before if statement
    j. If statements with nonzero static state simplify to contents
    h. If/loop statements with zero static state disappear

This can provide extreme performance boosts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant