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

Order of optimizations #99

Open
mhyee opened this issue May 1, 2017 · 1 comment
Open

Order of optimizations #99

mhyee opened this issue May 1, 2017 · 1 comment

Comments

@mhyee
Copy link
Member

mhyee commented May 1, 2017

This is mainly for discussion, maybe there isn't anything to do (right now).

Consider this example program:

mut w = 0
const z = w
w <- 1
print w
print z

If we run all optimization passes, the default order is to run make_const before hoist_assign. Here's what we get if we run with --opt=make_const,hoist_assign (I'm intentionally omitting some optimizations to keep the example simpler):

mut w_1 = 1
mut w = 0
const z = w
print w_1
print z

We removed the assignment, at the cost of adding another mut variable.

A better ordering is --opt=hoist_assign,make_const:

const w_1 = 1
const w = 0
const z = w
print w_1
print z

Now we eliminated the assignment and the mutable variable.


Was there a reason to put make_const before hoist_assign? Is there an optimal ordering of optimizations, or do we have to start thinking about fixpoints? (I guess this wouldn't be too difficult with the API we currently have.)

@o-
Copy link
Contributor

o- commented May 1, 2017

My idea with the current api was to run the optimizations in a loop until either fixpoint or upper limit on the number of iterations.

At least from my side there was no conscious decision about the ordering and as far as I know its an open question how different optimizations interact and what a good order is.

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

2 participants