Skip to content

Improve opt passes again #1050

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

Merged
merged 20 commits into from
Jan 10, 2020
Merged

Improve opt passes again #1050

merged 20 commits into from
Jan 10, 2020

Conversation

MaxGraey
Copy link
Member

@MaxGraey MaxGraey commented Jan 6, 2020

This also speed-up passing tests

@MaxGraey MaxGraey requested a review from dcodeIO January 6, 2020 23:23
@dcodeIO
Copy link
Member

dcodeIO commented Jan 7, 2020

Would be great to have even more comments around there as it's hard to tell what's going on, and why, and in the exact order. Worrying that we'll otherwise accumulate pass-bloat, forgetting why specific passes are at the location they are, becoming impossible to reason about questions like "do we actually need to run this pass here?".

// now that stuff-X has been reduced by pass-X we can optimize the resulting stuff-Y with pass-Y, doing explain-Y
add("Y");

Questions to ask to make a good comment:

  • What does this pass do?
  • Why at this location?
    • Which passes does this depend on?
    • Are there passes that should not be run before?
  • Why limited to this optimize or shrink level? (if applicable)
  • Why do we run this pass another time here? (if applicable)

@MaxGraey
Copy link
Member Author

MaxGraey commented Jan 7, 2020

Sure. I will try to describe all my steps, but it not always logical, sometimes just empirical find outs.

Btw I'm wondering is SSA used for globals? I guess it could optimize much more. See this for example:
https://github.com/AssemblyScript/assemblyscript/blob/6326ddf95408ac62775b24f7328c51235263d758/tests/compiler/logical.optimized.wat

@dcodeIO
Copy link
Member

dcodeIO commented Jan 7, 2020

Afaik (global ..) optimizations are relatively basic, limited to detecting single uses that are never reassigned and such. Especially C/C++ don't emit a lot of globals, so I guess it hasn't been a high priority.

@dcodeIO
Copy link
Member

dcodeIO commented Jan 9, 2020

In 005dfbc I rebuilt the allocator tests and noticed that though the untouched fixtures became a bit smaller, the optimized ones became larger. May this have something to do with pass order or is this unrelated?

@MaxGraey
Copy link
Member Author

MaxGraey commented Jan 9, 2020

tests/allocators don't update pretty often. See for example latest changes:

  (type $FUNCSIG$iii (func (param i32 i32) (result i32)))
  (type $FUNCSIG$ii (func (param i32) (result i32)))

to

 (type $i32_=>_none (func (param i32)))
 (type $none_=>_none (func))

and that old stub version didn't has maybeGrowMemory for example and other extra code which happened during long period

@MaxGraey
Copy link
Member Author

MaxGraey commented Jan 9, 2020

@dcodeIO btw I updated that tests in this PR as well and it significant reduce sizes:
https://github.com/AssemblyScript/assemblyscript/pull/1045/files#diff-c18c517ac7bd11043db66de8d39266de

@dcodeIO dcodeIO merged commit f700e2a into AssemblyScript:master Jan 10, 2020
@MaxGraey MaxGraey deleted the improve-passes branch January 10, 2020 13:01
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

Successfully merging this pull request may close these issues.

2 participants