Skip to content

Improve pass pipeline #1368

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 11 commits into from
Jul 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
25 changes: 19 additions & 6 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1512,6 +1512,7 @@ export class Module {
passes.push("flatten");
passes.push("simplify-locals-notee-nostructure");
passes.push("vacuum");

passes.push("code-folding");
passes.push("flatten");
passes.push("local-cse");
Expand All @@ -1529,8 +1530,10 @@ export class Module {
// passes.push("post-assemblyscript");
// }
passes.push("optimize-instructions");
passes.push("inlining");
passes.push("dce");
if (optimizeLevel >= 3 || shrinkLevel >= 1) {
passes.push("dce");
passes.push("inlining");
}
passes.push("remove-unused-brs");
passes.push("remove-unused-names");
passes.push("inlining-optimizing");
Expand All @@ -1549,11 +1552,13 @@ export class Module {
}
passes.push("simplify-locals-nostructure");
passes.push("vacuum");

passes.push("reorder-locals");
passes.push("remove-unused-brs");
passes.push("coalesce-locals");
passes.push("simplify-locals");
passes.push("vacuum");

passes.push("reorder-locals");
passes.push("coalesce-locals");
passes.push("reorder-locals");
Expand All @@ -1576,8 +1581,8 @@ export class Module {
}
if (optimizeLevel >= 2 || shrinkLevel >= 1) {
passes.push("rse");
passes.push("vacuum");
}
passes.push("vacuum");

// --- PassRunner::addDefaultGlobalOptimizationPostPasses ---

Expand Down Expand Up @@ -1623,22 +1628,30 @@ export class Module {
// very expensive, so O3 only
passes.push("simplify-globals");
passes.push("vacuum");

passes.push("precompute-propagate");
passes.push("vacuum");

// replace indirect with direct calls again and inline
passes.push("inlining-optimizing");
passes.push("directize");
passes.push("dae-optimizing");
passes.push("precompute-propagate");
passes.push("vacuum");

passes.push("merge-locals");
passes.push("coalesce-locals");
passes.push("simplify-locals-nostructure");
passes.push("simplify-locals");
passes.push("vacuum");

passes.push("inlining-optimizing");
passes.push("precompute-propagate");
passes.push("vacuum");

passes.push("coalesce-locals");
}
passes.push("remove-unused-brs");
passes.push("remove-unused-names");
passes.push("vacuum");

passes.push("optimize-instructions");
passes.push("simplify-globals-optimizing");
}
Expand Down
12 changes: 6 additions & 6 deletions tests/compiler/binary.optimized.wat
Original file line number Diff line number Diff line change
Expand Up @@ -114,17 +114,17 @@
local.get $1
i32.const 8388608
i32.ge_u
if
if (result i32)
local.get $1
i32.const 8388608
i32.eq
br_if $folding-inner0
local.get $1
i32.const 8388608
i32.sub
local.set $1
else
local.get $1
end
local.get $1
i32.const 1
i32.shl
local.set $1
Expand Down Expand Up @@ -261,17 +261,17 @@
local.get $1
i64.const 4503599627370496
i64.ge_u
if
if (result i64)
local.get $1
i64.const 4503599627370496
i64.eq
br_if $folding-inner0
local.get $1
i64.const 4503599627370496
i64.sub
local.set $1
else
local.get $1
end
local.get $1
i64.const 1
i64.shl
local.set $1
Expand Down
5 changes: 2 additions & 3 deletions tests/compiler/class-overloading.optimized.wat
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,11 @@
local.set $0
end
local.get $0
i32.eqz
if (result i32)
local.get $0
else
i32.const 3
call $~lib/rt/stub/__alloc
else
local.get $0
end
)
(func $~lib/string/String#get:length (param $0 i32) (result i32)
Expand Down
Loading