Skip to content

More aggressive inlining and slightly reworked pass pipeline again #1135

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 59 commits into from
Mar 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
aafdaa2
update
MaxGraey Feb 29, 2020
bc03e64
more
MaxGraey Feb 29, 2020
931a07d
use extended params only for shrinkLevel = 0
MaxGraey Feb 29, 2020
9e66bc4
better
MaxGraey Feb 29, 2020
e81a5d7
more
MaxGraey Feb 29, 2020
aa38d37
rebuild examples
MaxGraey Feb 29, 2020
1868ef3
slightly improve pass pipeline
MaxGraey Feb 29, 2020
8b4b83e
simplify-globals-optimizing -> simplify-globals without regress
MaxGraey Feb 29, 2020
a8cd1ed
swap optimize-instructions
MaxGraey Feb 29, 2020
9f3694f
rebuild examples again
MaxGraey Feb 29, 2020
2dbe139
add LICM pass
MaxGraey Feb 29, 2020
76f0a45
Merge branch 'master' into inline-tuning
MaxGraey Feb 29, 2020
c577392
rebuild game of life after merge
MaxGraey Feb 29, 2020
eaf9ba3
even more aggresive for single usage functions
MaxGraey Mar 1, 2020
f4c70ae
better
MaxGraey Mar 1, 2020
f179890
more
MaxGraey Mar 1, 2020
5a37bc3
finalize
MaxGraey Mar 1, 2020
e94b69c
pre-simplify for cse
MaxGraey Mar 1, 2020
0ac67d2
add comment
MaxGraey Mar 1, 2020
2d8fb42
remould g-o-l
MaxGraey Mar 1, 2020
49a561d
better
MaxGraey Mar 1, 2020
8d12ecd
rebuild examples
MaxGraey Mar 1, 2020
42b36eb
more
MaxGraey Mar 1, 2020
a3a58fd
reorder for better compile perf
MaxGraey Mar 1, 2020
b2409cd
better
MaxGraey Mar 1, 2020
0712e76
perfect!
MaxGraey Mar 1, 2020
fcae8e9
Merge branch 'master' into inline-tuning
MaxGraey Mar 3, 2020
38e9771
rebuild
MaxGraey Mar 3, 2020
f7519ef
cleanups
MaxGraey Mar 3, 2020
a1f73ff
add finalize dead arg elim pass
MaxGraey Mar 3, 2020
a3ca9c9
more
MaxGraey Mar 3, 2020
fe90d14
better
MaxGraey Mar 3, 2020
06c4327
better
MaxGraey Mar 3, 2020
58fb875
more
MaxGraey Mar 3, 2020
da5f691
rebuild examples
MaxGraey Mar 3, 2020
08577d2
better
MaxGraey Mar 3, 2020
6fe8a23
Merge branch 'master' into inline-tuning
MaxGraey Mar 3, 2020
42ed39c
add special case for high shrink level as well
MaxGraey Mar 3, 2020
94bea8f
extra merge locals
MaxGraey Mar 6, 2020
8c31f63
better
MaxGraey Mar 6, 2020
2e46863
move dae-optimizing after directize
MaxGraey Mar 6, 2020
23ac0a7
remove unnecessary reorder-local
MaxGraey Mar 6, 2020
eded5ab
rebuild examples
MaxGraey Mar 6, 2020
954142f
use simplify-locals-notee-nostructure for early pass
MaxGraey Mar 6, 2020
2dcf5d6
revert last commit
MaxGraey Mar 6, 2020
96235fe
Merge branch 'master' into inline-tuning
MaxGraey Mar 10, 2020
f4c8e5f
rebuild
MaxGraey Mar 10, 2020
ce98ea5
Merge branch 'master' into inline-tuning
MaxGraey Mar 10, 2020
4347aaf
Merge branch 'master' into inline-tuning
MaxGraey Mar 10, 2020
5d0075a
rebuild
MaxGraey Mar 10, 2020
19d11bb
Merge branch 'master' into inline-tuning
MaxGraey Mar 12, 2020
d9b8968
early rse
MaxGraey Mar 12, 2020
9437449
and second rse
MaxGraey Mar 12, 2020
2fd004e
rebuild examples
MaxGraey Mar 12, 2020
bfef339
add early rse
MaxGraey Mar 12, 2020
aecd405
cleanups
MaxGraey Mar 12, 2020
777b2da
enhance setAlwaysInlineMaxSize treshold
MaxGraey Mar 13, 2020
0f6288d
sync with master
MaxGraey Mar 13, 2020
dfbce8e
rebuild
MaxGraey Mar 13, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 41 additions & 17 deletions cli/asc.js
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,20 @@ exports.main = function main(argv, options, callback) {
const passes = [];
function add(pass) { passes.push(pass); }

if (optimizeLevel >= 2 && shrinkLevel === 0) {
// tweak inlining options when speed more preferable than size
module.setAlwaysInlineMaxSize(12);
module.setFlexibleInlineMaxSize(70);
module.setOneCallerInlineMaxSize(200);
} else {
// tweak inlining options when size matters
optimizeLevel === 0 && shrinkLevel >= 0
? module.setAlwaysInlineMaxSize(2)
: module.setAlwaysInlineMaxSize(4); // default: 2
module.setFlexibleInlineMaxSize(65); // default: 20
module.setOneCallerInlineMaxSize(80); // default: 15
}

// Optimize the module if requested
if (optimizeLevel > 0 || shrinkLevel > 0) {
// Binaryen's default passes with Post-AssemblyScript passes added.
Expand All @@ -691,9 +705,15 @@ exports.main = function main(argv, options, callback) {
add("ssa-nomerge");
}
if (optimizeLevel >= 3) {
add("simplify-locals-nostructure"); // differs
add("vacuum"); // differs
add("reorder-locals"); // differs
add("flatten");
add("local-cse");
}
if (optimizeLevel >= 2 || shrinkLevel >= 1) { // differs
add("rse");
}
if (hasARC) { // differs
if (optimizeLevel < 3) {
add("flatten");
Expand All @@ -703,11 +723,12 @@ exports.main = function main(argv, options, callback) {
add("dce");
add("remove-unused-brs");
add("remove-unused-names");
add("optimize-instructions");
// add("optimize-instructions"); // differs move 2 lines above
if (optimizeLevel >= 2 || shrinkLevel >= 1) {
add("pick-load-signs");
add("simplify-globals-optimizing"); // differs
}
add("optimize-instructions"); // differs
if (optimizeLevel >= 3 || shrinkLevel >= 2) {
add("precompute-propagate");
} else {
Expand All @@ -717,19 +738,25 @@ exports.main = function main(argv, options, callback) {
// if (optimizeLevel >= 2 || shrinkLevel >= 2) {
// add("code-pushing");
// }
if (optimizeLevel >= 3 && shrinkLevel <= 1) { // differs
add("licm");
}
add("simplify-locals-nostructure");
add("vacuum");
add("reorder-locals");
add("remove-unused-brs");
if (optimizeLevel >= 3 || shrinkLevel >= 2) {
add("merge-locals");
}
// if (optimizeLevel >= 3 || shrinkLevel >= 2) { // do it later
// add("merge-locals");
// }
add("coalesce-locals");
add("simplify-locals");
add("vacuum");
add("reorder-locals");
add("coalesce-locals");
add("reorder-locals");
if (optimizeLevel >= 3 || shrinkLevel >= 1) { // differs
add("merge-locals");
}
add("vacuum");
if (optimizeLevel >= 3 || shrinkLevel >= 1) {
add("code-folding");
Expand Down Expand Up @@ -789,29 +816,26 @@ exports.main = function main(argv, options, callback) {
add("remove-unused-brs");
add("vacuum");

// replace indirect calls with direct and inline if possible again.
add("directize");
add("inlining-optimizing");
// move some code after early return which potentially could reduce computations
// do this after CFG cleanup (originally it was done before)
// moved from (1)
add("code-pushing");

// this quite expensive so do this only for highest opt level
add("simplify-globals-optimizing");
if (optimizeLevel >= 3) {
add("simplify-locals-nostructure");
add("vacuum");

// this quite expensive so do this only for highest opt level
add("simplify-globals");
// replace indirect calls with direct and inline if possible again.
add("directize");
add("dae-optimizing");
add("precompute-propagate");
add("coalesce-locals");
add("merge-locals");
add("simplify-locals-nostructure");
add("vacuum");

add("reorder-locals");
} else {
add("simplify-globals-optimizing");
add("inlining-optimizing");
add("precompute-propagate");
}
add("optimize-instructions");
add("simplify-globals-optimizing");
}
// remove unused elements of table and pack / reduce memory
add("duplicate-function-elimination"); // differs
Expand Down
4 changes: 4 additions & 0 deletions examples/game-of-life/build/optimized.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ declare module ASModule {
type i8 = number;
type i16 = number;
type i32 = number;
type i64 = BigInt;
type isize = number;
type u8 = number;
type u16 = number;
type u32 = number;
type u64 = BigInt;
type usize = number;
type f32 = number;
type f64 = number;
type bool = any;
Expand Down
Binary file modified examples/game-of-life/build/optimized.wasm
Binary file not shown.
Loading