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

Ideas for AST-level optimizations #1972

Open
iamdefinitelyahuman opened this issue May 14, 2020 · 0 comments
Open

Ideas for AST-level optimizations #1972

iamdefinitelyahuman opened this issue May 14, 2020 · 0 comments
Labels
Optimization Issues related to compiler optimization

Comments

@iamdefinitelyahuman
Copy link
Contributor

iamdefinitelyahuman commented May 14, 2020

This is a list of ideas for optimizations that could be implemented via AST modification. Some of these ideas are probably bad. This is a living list, in no way finalized, and will likely change in the future.

  • in __init__, remove any assignments of self.var = [zero value]
  • when a storage variable is referenced more than once without being written to, create a memory variable
  • remove memory variables that are initialized but never used
  • for an if statement where both the if and else blocks end in a return, move the else block logic into the body of the parent block (note: potential scoping concerns)
  • convert > 0 to != 0 for unsigned integer comparisons
  • if a memory variable is initialized and only referenced once, replace the reference with the right-hand side of the initialization
  • if the final node in a function body is a for loop, and the function returns None, replace any return statements inside the function with break
  • if constant folding results in if True: or if False: remove the block or the else block (consider scoping here)
  • within the context of a for loop, if there are multiple lookups of some_long_array[i] without any assignments, copy the value to a new memory value to save on lookups
@iamdefinitelyahuman iamdefinitelyahuman added the VIP: Discussion Used to denote VIPs and more complex issues that are waiting discussion in a meeting label May 14, 2020
@iamdefinitelyahuman iamdefinitelyahuman added Optimization Issues related to compiler optimization and removed VIP: Discussion Used to denote VIPs and more complex issues that are waiting discussion in a meeting labels Jul 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Optimization Issues related to compiler optimization
Projects
None yet
Development

No branches or pull requests

1 participant