Skip to content

Slightly improve pass pipeline #2028

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 5 commits into from
Aug 13, 2021
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
16 changes: 6 additions & 10 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2247,7 +2247,6 @@ export class Module {
// --- PassRunner::addDefaultFunctionOptimizationPasses ---

if (optimizeLevel >= 3 || shrinkLevel >= 1) {
passes.push("simplify-locals-notee-nostructure");
passes.push("rse");
passes.push("vacuum");
passes.push("ssa-nomerge");
Expand All @@ -2258,16 +2257,16 @@ export class Module {
passes.push("precompute-propagate");
}
if (optimizeLevel >= 3) {
passes.push("flatten");
passes.push("vacuum");
passes.push("simplify-locals-notee-nostructure");
passes.push("merge-locals");

passes.push("code-folding");
passes.push("flatten");
passes.push("vacuum");
passes.push("local-cse");
passes.push("licm");
passes.push("simplify-locals-notee-nostructure");
passes.push("merge-locals");
passes.push("reorder-locals");
passes.push("dae-optimizing");
passes.push("code-folding");
}
passes.push("optimize-instructions");
if (optimizeLevel >= 3 || shrinkLevel >= 1) {
Expand All @@ -2285,10 +2284,7 @@ export class Module {
passes.push("pick-load-signs");
passes.push("simplify-globals-optimizing");
}
if (optimizeLevel >= 3 && shrinkLevel <= 1) {
passes.push("licm");
}
passes.push("simplify-locals-nostructure");
passes.push("simplify-locals-notee-nostructure");
passes.push("vacuum");

passes.push("reorder-locals");
Expand Down
43 changes: 20 additions & 23 deletions tests/compiler/NonNullable.optimized.wat
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
i32.load offset=16
i32.const 1
i32.shr_u
local.tee $4
local.tee $2
local.get $1
i32.const 20
i32.sub
Expand All @@ -59,39 +59,36 @@
end
block $__inlined_func$~lib/util/string/compareImpl (result i32)
local.get $0
local.set $2
local.get $1
local.set $3
local.get $2
local.tee $3
i32.const 7
i32.and
local.get $3
local.get $1
i32.const 7
i32.and
i32.or
i32.const 1
local.get $4
local.get $2
local.tee $0
i32.const 4
i32.ge_u
select
i32.eqz
if
loop $do-continue|0
local.get $2
i64.load
local.get $3
i64.load
local.get $1
i64.load
i64.eq
if
local.get $2
i32.const 8
i32.add
local.set $2
local.get $3
i32.const 8
i32.add
local.set $3
local.get $1
i32.const 8
i32.add
local.set $1
local.get $0
i32.const 4
i32.sub
Expand All @@ -104,33 +101,33 @@
end
loop $while-continue|1
local.get $0
local.tee $1
local.tee $2
i32.const 1
i32.sub
local.set $0
local.get $1
local.get $2
if
local.get $2
i32.load16_u
local.tee $1
local.get $3
i32.load16_u
local.tee $2
local.get $1
i32.load16_u
local.tee $4
i32.ne
if
local.get $1
local.get $2
local.get $4
i32.sub
br $__inlined_func$~lib/util/string/compareImpl
end
local.get $2
i32.const 2
i32.add
local.set $2
local.get $3
i32.const 2
i32.add
local.set $3
local.get $1
i32.const 2
i32.add
local.set $1
br $while-continue|1
end
end
Expand Down
8 changes: 4 additions & 4 deletions tests/compiler/assert-nonnull.optimized.wat
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,11 @@
i32.const 4
i32.sub
global.set $~lib/memory/__stack_pointer
block $folding-inner1
block $folding-inner0
global.get $~lib/memory/__stack_pointer
i32.const 1404
i32.lt_s
br_if $folding-inner1
br_if $folding-inner0
global.get $~lib/memory/__stack_pointer
local.tee $1
local.get $0
Expand All @@ -226,7 +226,7 @@
global.get $~lib/memory/__stack_pointer
i32.const 1404
i32.lt_s
br_if $folding-inner1
br_if $folding-inner0
global.get $~lib/memory/__stack_pointer
i32.const 0
i32.store
Expand All @@ -251,7 +251,7 @@
global.get $~lib/memory/__stack_pointer
i32.const 1404
i32.lt_s
br_if $folding-inner1
br_if $folding-inner0
global.get $~lib/memory/__stack_pointer
i32.const 0
i32.store
Expand Down
18 changes: 2 additions & 16 deletions tests/compiler/binary.optimized.wat
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,6 @@
(func $~start
(local $0 f32)
(local $1 f64)
block $__inlined_func$~lib/math/ipow32
global.get $binary/i
i32.const 2
i32.eq
br_if $__inlined_func$~lib/math/ipow32
end
global.get $binary/i
i32.const 1
i32.add
Expand All @@ -166,13 +160,9 @@
global.set $binary/i
i32.const 0
global.set $binary/i
global.get $binary/i
i32.const 1
i32.and
i32.const 0
global.set $binary/i
global.get $binary/i
i32.const 1
i32.or
global.set $binary/i
global.get $binary/i
i32.const 1
Expand Down Expand Up @@ -218,13 +208,9 @@
global.set $binary/I
i64.const 0
global.set $binary/I
global.get $binary/I
i64.const 1
i64.and
i64.const 0
global.set $binary/I
global.get $binary/I
i64.const 1
i64.or
global.set $binary/I
global.get $binary/I
i64.const 1
Expand Down
43 changes: 20 additions & 23 deletions tests/compiler/builtins.optimized.wat
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
i32.load offset=16
i32.const 1
i32.shr_u
local.tee $4
local.tee $2
local.get $1
i32.const 20
i32.sub
Expand All @@ -115,39 +115,36 @@
end
block $__inlined_func$~lib/util/string/compareImpl (result i32)
local.get $0
local.set $2
local.get $1
local.set $3
local.get $2
local.tee $3
i32.const 7
i32.and
local.get $3
local.get $1
i32.const 7
i32.and
i32.or
i32.const 1
local.get $4
local.get $2
local.tee $0
i32.const 4
i32.ge_u
select
i32.eqz
if
loop $do-continue|0
local.get $2
i64.load
local.get $3
i64.load
local.get $1
i64.load
i64.eq
if
local.get $2
i32.const 8
i32.add
local.set $2
local.get $3
i32.const 8
i32.add
local.set $3
local.get $1
i32.const 8
i32.add
local.set $1
local.get $0
i32.const 4
i32.sub
Expand All @@ -160,33 +157,33 @@
end
loop $while-continue|1
local.get $0
local.tee $1
local.tee $2
i32.const 1
i32.sub
local.set $0
local.get $1
local.get $2
if
local.get $2
i32.load16_u
local.tee $1
local.get $3
i32.load16_u
local.tee $2
local.get $1
i32.load16_u
local.tee $4
i32.ne
if
local.get $1
local.get $2
local.get $4
i32.sub
br $__inlined_func$~lib/util/string/compareImpl
end
local.get $2
i32.const 2
i32.add
local.set $2
local.get $3
i32.const 2
i32.add
local.set $3
local.get $1
i32.const 2
i32.add
local.set $1
br $while-continue|1
end
end
Expand Down
Loading