Skip to content

Commit

Permalink
Slightly improve pass pipeline (#1498)
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxGraey authored Oct 12, 2020
1 parent a5d11ed commit b4ca3f9
Show file tree
Hide file tree
Showing 12 changed files with 5,015 additions and 5,065 deletions.
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");
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

0 comments on commit b4ca3f9

Please sign in to comment.