Skip to content

Commit 91b531c

Browse files
authored
Slightly improve pass pipeline (#2028)
1 parent ecf28b1 commit 91b531c

File tree

90 files changed

+43169
-44043
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+43169
-44043
lines changed

src/module.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2247,7 +2247,6 @@ export class Module {
22472247
// --- PassRunner::addDefaultFunctionOptimizationPasses ---
22482248

22492249
if (optimizeLevel >= 3 || shrinkLevel >= 1) {
2250-
passes.push("simplify-locals-notee-nostructure");
22512250
passes.push("rse");
22522251
passes.push("vacuum");
22532252
passes.push("ssa-nomerge");
@@ -2258,16 +2257,16 @@ export class Module {
22582257
passes.push("precompute-propagate");
22592258
}
22602259
if (optimizeLevel >= 3) {
2261-
passes.push("flatten");
2262-
passes.push("vacuum");
22632260
passes.push("simplify-locals-notee-nostructure");
2264-
passes.push("merge-locals");
2265-
2266-
passes.push("code-folding");
22672261
passes.push("flatten");
22682262
passes.push("vacuum");
22692263
passes.push("local-cse");
2264+
passes.push("licm");
2265+
passes.push("simplify-locals-notee-nostructure");
2266+
passes.push("merge-locals");
22702267
passes.push("reorder-locals");
2268+
passes.push("dae-optimizing");
2269+
passes.push("code-folding");
22712270
}
22722271
passes.push("optimize-instructions");
22732272
if (optimizeLevel >= 3 || shrinkLevel >= 1) {
@@ -2285,10 +2284,7 @@ export class Module {
22852284
passes.push("pick-load-signs");
22862285
passes.push("simplify-globals-optimizing");
22872286
}
2288-
if (optimizeLevel >= 3 && shrinkLevel <= 1) {
2289-
passes.push("licm");
2290-
}
2291-
passes.push("simplify-locals-nostructure");
2287+
passes.push("simplify-locals-notee-nostructure");
22922288
passes.push("vacuum");
22932289

22942290
passes.push("reorder-locals");

tests/compiler/NonNullable.optimized.wat

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
i32.load offset=16
4646
i32.const 1
4747
i32.shr_u
48-
local.tee $4
48+
local.tee $2
4949
local.get $1
5050
i32.const 20
5151
i32.sub
@@ -59,39 +59,36 @@
5959
end
6060
block $__inlined_func$~lib/util/string/compareImpl (result i32)
6161
local.get $0
62-
local.set $2
63-
local.get $1
64-
local.set $3
65-
local.get $2
62+
local.tee $3
6663
i32.const 7
6764
i32.and
68-
local.get $3
65+
local.get $1
6966
i32.const 7
7067
i32.and
7168
i32.or
7269
i32.const 1
73-
local.get $4
70+
local.get $2
7471
local.tee $0
7572
i32.const 4
7673
i32.ge_u
7774
select
7875
i32.eqz
7976
if
8077
loop $do-continue|0
81-
local.get $2
82-
i64.load
8378
local.get $3
8479
i64.load
80+
local.get $1
81+
i64.load
8582
i64.eq
8683
if
87-
local.get $2
88-
i32.const 8
89-
i32.add
90-
local.set $2
9184
local.get $3
9285
i32.const 8
9386
i32.add
9487
local.set $3
88+
local.get $1
89+
i32.const 8
90+
i32.add
91+
local.set $1
9592
local.get $0
9693
i32.const 4
9794
i32.sub
@@ -104,33 +101,33 @@
104101
end
105102
loop $while-continue|1
106103
local.get $0
107-
local.tee $1
104+
local.tee $2
108105
i32.const 1
109106
i32.sub
110107
local.set $0
111-
local.get $1
108+
local.get $2
112109
if
113-
local.get $2
114-
i32.load16_u
115-
local.tee $1
116110
local.get $3
117111
i32.load16_u
112+
local.tee $2
113+
local.get $1
114+
i32.load16_u
118115
local.tee $4
119116
i32.ne
120117
if
121-
local.get $1
118+
local.get $2
122119
local.get $4
123120
i32.sub
124121
br $__inlined_func$~lib/util/string/compareImpl
125122
end
126-
local.get $2
127-
i32.const 2
128-
i32.add
129-
local.set $2
130123
local.get $3
131124
i32.const 2
132125
i32.add
133126
local.set $3
127+
local.get $1
128+
i32.const 2
129+
i32.add
130+
local.set $1
134131
br $while-continue|1
135132
end
136133
end

tests/compiler/assert-nonnull.optimized.wat

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,11 @@
210210
i32.const 4
211211
i32.sub
212212
global.set $~lib/memory/__stack_pointer
213-
block $folding-inner1
213+
block $folding-inner0
214214
global.get $~lib/memory/__stack_pointer
215215
i32.const 1404
216216
i32.lt_s
217-
br_if $folding-inner1
217+
br_if $folding-inner0
218218
global.get $~lib/memory/__stack_pointer
219219
local.tee $1
220220
local.get $0
@@ -226,7 +226,7 @@
226226
global.get $~lib/memory/__stack_pointer
227227
i32.const 1404
228228
i32.lt_s
229-
br_if $folding-inner1
229+
br_if $folding-inner0
230230
global.get $~lib/memory/__stack_pointer
231231
i32.const 0
232232
i32.store
@@ -251,7 +251,7 @@
251251
global.get $~lib/memory/__stack_pointer
252252
i32.const 1404
253253
i32.lt_s
254-
br_if $folding-inner1
254+
br_if $folding-inner0
255255
global.get $~lib/memory/__stack_pointer
256256
i32.const 0
257257
i32.store

tests/compiler/binary.optimized.wat

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,6 @@
142142
(func $~start
143143
(local $0 f32)
144144
(local $1 f64)
145-
block $__inlined_func$~lib/math/ipow32
146-
global.get $binary/i
147-
i32.const 2
148-
i32.eq
149-
br_if $__inlined_func$~lib/math/ipow32
150-
end
151145
global.get $binary/i
152146
i32.const 1
153147
i32.add
@@ -166,13 +160,9 @@
166160
global.set $binary/i
167161
i32.const 0
168162
global.set $binary/i
169-
global.get $binary/i
170-
i32.const 1
171-
i32.and
163+
i32.const 0
172164
global.set $binary/i
173-
global.get $binary/i
174165
i32.const 1
175-
i32.or
176166
global.set $binary/i
177167
global.get $binary/i
178168
i32.const 1
@@ -218,13 +208,9 @@
218208
global.set $binary/I
219209
i64.const 0
220210
global.set $binary/I
221-
global.get $binary/I
222-
i64.const 1
223-
i64.and
211+
i64.const 0
224212
global.set $binary/I
225-
global.get $binary/I
226213
i64.const 1
227-
i64.or
228214
global.set $binary/I
229215
global.get $binary/I
230216
i64.const 1

tests/compiler/builtins.optimized.wat

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
i32.load offset=16
102102
i32.const 1
103103
i32.shr_u
104-
local.tee $4
104+
local.tee $2
105105
local.get $1
106106
i32.const 20
107107
i32.sub
@@ -115,39 +115,36 @@
115115
end
116116
block $__inlined_func$~lib/util/string/compareImpl (result i32)
117117
local.get $0
118-
local.set $2
119-
local.get $1
120-
local.set $3
121-
local.get $2
118+
local.tee $3
122119
i32.const 7
123120
i32.and
124-
local.get $3
121+
local.get $1
125122
i32.const 7
126123
i32.and
127124
i32.or
128125
i32.const 1
129-
local.get $4
126+
local.get $2
130127
local.tee $0
131128
i32.const 4
132129
i32.ge_u
133130
select
134131
i32.eqz
135132
if
136133
loop $do-continue|0
137-
local.get $2
138-
i64.load
139134
local.get $3
140135
i64.load
136+
local.get $1
137+
i64.load
141138
i64.eq
142139
if
143-
local.get $2
144-
i32.const 8
145-
i32.add
146-
local.set $2
147140
local.get $3
148141
i32.const 8
149142
i32.add
150143
local.set $3
144+
local.get $1
145+
i32.const 8
146+
i32.add
147+
local.set $1
151148
local.get $0
152149
i32.const 4
153150
i32.sub
@@ -160,33 +157,33 @@
160157
end
161158
loop $while-continue|1
162159
local.get $0
163-
local.tee $1
160+
local.tee $2
164161
i32.const 1
165162
i32.sub
166163
local.set $0
167-
local.get $1
164+
local.get $2
168165
if
169-
local.get $2
170-
i32.load16_u
171-
local.tee $1
172166
local.get $3
173167
i32.load16_u
168+
local.tee $2
169+
local.get $1
170+
i32.load16_u
174171
local.tee $4
175172
i32.ne
176173
if
177-
local.get $1
174+
local.get $2
178175
local.get $4
179176
i32.sub
180177
br $__inlined_func$~lib/util/string/compareImpl
181178
end
182-
local.get $2
183-
i32.const 2
184-
i32.add
185-
local.set $2
186179
local.get $3
187180
i32.const 2
188181
i32.add
189182
local.set $3
183+
local.get $1
184+
i32.const 2
185+
i32.add
186+
local.set $1
190187
br $while-continue|1
191188
end
192189
end

0 commit comments

Comments
 (0)