Skip to content

Slightly improve pass pipeline #1498

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 10 commits into from
Oct 12, 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
14 changes: 7 additions & 7 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1526,11 +1526,12 @@ export class Module {
passes.push("remove-unused-brs");
passes.push("remove-unused-names");
passes.push("merge-blocks");
passes.push("precompute");
passes.push("precompute-propagate");
}
if (optimizeLevel >= 3) {
passes.push("flatten");
passes.push("simplify-locals-notee-nostructure");
passes.push("merge-locals");
passes.push("vacuum");

passes.push("code-folding");
Expand All @@ -1548,12 +1549,11 @@ export class Module {
passes.push("optimize-instructions");
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");
if (optimizeLevel >= 3 || shrinkLevel >= 2) {
passes.push("inlining");
passes.push("precompute-propagate");
} else {
passes.push("precompute");
Expand Down Expand Up @@ -1581,9 +1581,6 @@ export class Module {
passes.push("merge-locals");
}
passes.push("vacuum");
if (optimizeLevel >= 3 || shrinkLevel >= 1) {
passes.push("code-folding");
}
if (optimizeLevel >= 2 || shrinkLevel >= 1) {
passes.push("simplify-globals-optimizing");
}
Expand Down Expand Up @@ -1622,6 +1619,9 @@ export class Module {
passes.push("simplify-globals");
passes.push("vacuum");
}
if (optimizeLevel >= 3 || shrinkLevel >= 1) {
passes.push("code-folding");
}
// precompute works best after global optimizations
if (optimizeLevel >= 2 || shrinkLevel >= 1) {
passes.push("precompute-propagate");
Expand Down Expand Up @@ -1656,7 +1656,7 @@ export class Module {
passes.push("simplify-locals");
passes.push("vacuum");

passes.push("inlining-optimizing");
passes.push("inlining");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious: What's the different between inlining and inlining-optimizing? Is the latter unnecessary?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems inlining-optimizing also apply constant propagation but only for specific part or something like this

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

Expand Down
28 changes: 14 additions & 14 deletions tests/compiler/issues/1095.optimized.wat
Original file line number Diff line number Diff line change
Expand Up @@ -952,16 +952,16 @@
i32.const 16
i32.add
call $~lib/rt/pure/__retain
local.tee $3
local.tee $2
i32.const 1200
i32.store
local.get $3
local.get $2
call $~lib/rt/pure/__retain
local.tee $1
local.set $2
local.get $1
i32.load
local.tee $0
local.set $3
local.get $0
i32.load
local.tee $1
i32.eqz
if
i32.const 1232
Expand All @@ -971,25 +971,25 @@
call $~lib/builtins/abort
unreachable
end
local.get $1
local.get $0
local.get $2
i32.load
local.tee $2
local.tee $0
i32.ne
if
local.get $0
local.get $1
call $~lib/rt/pure/__retain
local.set $0
local.get $2
local.set $1
local.get $0
call $~lib/rt/pure/__release
end
local.get $3
local.get $1
local.get $0
i32.store
local.get $1
call $~lib/rt/pure/__release
local.get $3
call $~lib/rt/pure/__release
local.get $2
call $~lib/rt/pure/__release
)
(func $~lib/rt/pure/decrement (param $0 i32)
(local $1 i32)
Expand Down
Loading