Skip to content

Commit 42faca2

Browse files
committed
apply rse later
1 parent 418855e commit 42faca2

37 files changed

+1209
-1183
lines changed

src/module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1519,7 +1519,6 @@ export class Module {
15191519

15201520
if (optimizeLevel >= 3 || shrinkLevel >= 1) {
15211521
passes.push("simplify-locals-notee-nostructure");
1522-
passes.push("rse");
15231522
passes.push("vacuum");
15241523
passes.push("ssa-nomerge");
15251524
passes.push("simplify-globals-optimizing");
@@ -1547,6 +1546,7 @@ export class Module {
15471546
// }
15481547
passes.push("optimize-instructions");
15491548
if (optimizeLevel >= 3 || shrinkLevel >= 1) {
1549+
passes.push("rse");
15501550
passes.push("dce");
15511551
}
15521552
passes.push("remove-unused-brs");

tests/compiler/comma.optimized.wat

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@
1010
(start $~start)
1111
(func $start:comma
1212
(local $0 i32)
13-
(local $1 i32)
1413
global.get $comma/a
15-
local.tee $1
14+
local.tee $0
1615
i32.const 1
1716
i32.add
1817
global.set $comma/a
19-
local.get $1
18+
local.get $0
2019
global.set $comma/b
2120
global.get $comma/a
2221
i32.const 1
@@ -80,6 +79,8 @@
8079
global.set $comma/b
8180
i32.const 2
8281
global.set $comma/a
82+
i32.const 0
83+
local.set $0
8384
loop $for-loop|0
8485
local.get $0
8586
global.get $comma/a

tests/compiler/do.optimized.wat

Lines changed: 64 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -683,26 +683,26 @@
683683
i32.const 0
684684
i32.store
685685
loop $for-loop|0
686-
local.get $0
686+
local.get $2
687687
i32.const 23
688688
i32.lt_u
689689
if
690-
local.get $0
690+
local.get $2
691691
i32.const 2
692692
i32.shl
693693
i32.const 1216
694694
i32.add
695695
i32.const 0
696696
i32.store offset=4
697697
i32.const 0
698-
local.set $2
698+
local.set $0
699699
loop $for-loop|1
700-
local.get $2
700+
local.get $0
701701
i32.const 16
702702
i32.lt_u
703703
if
704-
local.get $2
705704
local.get $0
705+
local.get $2
706706
i32.const 4
707707
i32.shl
708708
i32.add
@@ -712,17 +712,17 @@
712712
i32.add
713713
i32.const 0
714714
i32.store offset=96
715-
local.get $2
715+
local.get $0
716716
i32.const 1
717717
i32.add
718-
local.set $2
718+
local.set $0
719719
br $for-loop|1
720720
end
721721
end
722-
local.get $0
722+
local.get $2
723723
i32.const 1
724724
i32.add
725-
local.set $0
725+
local.set $2
726726
br $for-loop|0
727727
end
728728
end
@@ -1028,22 +1028,23 @@
10281028
(local $0 i32)
10291029
(local $1 i32)
10301030
(local $2 i32)
1031+
(local $3 i32)
10311032
i32.const 0
10321033
global.set $do/ran
10331034
i32.const 10
1034-
local.set $0
1035+
local.set $1
10351036
loop $do-continue|0
1036-
local.get $1
1037+
local.get $0
10371038
i32.const 1
10381039
i32.add
1039-
local.set $1
1040-
local.get $0
1040+
local.set $0
1041+
local.get $1
10411042
i32.const 1
10421043
i32.sub
1043-
local.tee $0
1044+
local.tee $1
10441045
br_if $do-continue|0
10451046
end
1046-
local.get $0
1047+
local.get $1
10471048
if
10481049
i32.const 0
10491050
i32.const 1040
@@ -1052,7 +1053,7 @@
10521053
call $~lib/builtins/abort
10531054
unreachable
10541055
end
1055-
local.get $1
1056+
local.get $0
10561057
i32.const 10
10571058
i32.ne
10581059
if
@@ -1068,17 +1069,17 @@
10681069
i32.const 0
10691070
global.set $do/ran
10701071
i32.const 10
1071-
local.set $1
1072+
local.set $0
10721073
loop $do-continue|00
1073-
local.get $1
1074-
local.tee $0
1074+
local.get $0
1075+
local.tee $1
10751076
i32.const 1
10761077
i32.sub
1077-
local.set $1
1078-
local.get $0
1078+
local.set $0
1079+
local.get $1
10791080
br_if $do-continue|00
10801081
end
1081-
local.get $1
1082+
local.get $0
10821083
i32.const -1
10831084
i32.ne
10841085
if
@@ -1108,14 +1109,14 @@
11081109
global.set $do/ran
11091110
i32.const 0
11101111
local.set $0
1111-
loop $do-continue|01
1112+
loop $do-continue|001
11121113
local.get $0
11131114
i32.const 1
11141115
i32.add
11151116
local.tee $0
11161117
i32.const 10
11171118
i32.ne
1118-
br_if $do-continue|01
1119+
br_if $do-continue|001
11191120
end
11201121
local.get $0
11211122
i32.const 10
@@ -1132,14 +1133,14 @@
11321133
global.set $do/ran
11331134
i32.const 0
11341135
local.set $0
1135-
loop $do-continue|02
1136+
loop $do-continue|01
11361137
local.get $0
11371138
i32.const 1
11381139
i32.add
11391140
local.tee $0
11401141
i32.const 10
11411142
i32.ne
1142-
br_if $do-continue|02
1143+
br_if $do-continue|01
11431144
end
11441145
local.get $0
11451146
i32.const 10
@@ -1168,14 +1169,14 @@
11681169
global.set $do/ran
11691170
i32.const 0
11701171
local.set $0
1171-
loop $do-continue|03
1172+
loop $do-continue|02
11721173
local.get $0
11731174
i32.const 1
11741175
i32.add
11751176
local.tee $0
11761177
i32.const 10
11771178
i32.ne
1178-
br_if $do-continue|03
1179+
br_if $do-continue|02
11791180
end
11801181
local.get $0
11811182
i32.const 10
@@ -1193,30 +1194,30 @@
11931194
i32.const 0
11941195
global.set $do/ran
11951196
i32.const 0
1196-
local.set $1
1197-
i32.const 0
11981197
local.set $0
1199-
loop $do-continue|04
1200-
local.get $1
1198+
i32.const 0
1199+
local.set $1
1200+
loop $do-continue|03
1201+
local.get $0
12011202
i32.const 1
12021203
i32.add
1203-
local.tee $1
1204+
local.tee $0
12041205
i32.const 10
12051206
i32.ne
12061207
if
12071208
loop $do-continue|1
1208-
local.get $0
1209+
local.get $1
12091210
i32.const 1
12101211
i32.add
1211-
local.tee $0
1212+
local.tee $1
12121213
i32.const 10
12131214
i32.rem_s
12141215
br_if $do-continue|1
12151216
end
1216-
br $do-continue|04
1217+
br $do-continue|03
12171218
end
12181219
end
1219-
local.get $1
1220+
local.get $0
12201221
i32.const 10
12211222
i32.ne
12221223
if
@@ -1227,7 +1228,7 @@
12271228
call $~lib/builtins/abort
12281229
unreachable
12291230
end
1230-
local.get $0
1231+
local.get $1
12311232
i32.const 90
12321233
i32.ne
12331234
if
@@ -1247,8 +1248,8 @@
12471248
i32.const 16
12481249
i32.add
12491250
call $~lib/rt/pure/__retain
1250-
local.set $1
1251-
loop $do-continue|05
1251+
local.set $0
1252+
loop $do-continue|04
12521253
local.get $2
12531254
i32.const 1
12541255
i32.add
@@ -1257,10 +1258,10 @@
12571258
i32.eq
12581259
if
12591260
i32.const 0
1260-
local.set $0
1261-
local.get $1
1261+
local.set $1
1262+
local.get $0
12621263
if
1263-
local.get $1
1264+
local.get $0
12641265
call $~lib/rt/pure/__release
12651266
end
12661267
else
@@ -1269,13 +1270,13 @@
12691270
i32.const 16
12701271
i32.add
12711272
call $~lib/rt/pure/__retain
1272-
local.set $0
1273-
local.get $1
1273+
local.set $1
1274+
local.get $0
12741275
call $~lib/rt/pure/__release
12751276
end
1276-
local.get $0
1277-
local.tee $1
1278-
br_if $do-continue|05
1277+
local.get $1
1278+
local.tee $0
1279+
br_if $do-continue|04
12791280
end
12801281
local.get $2
12811282
i32.const 10
@@ -1288,7 +1289,7 @@
12881289
call $~lib/builtins/abort
12891290
unreachable
12901291
end
1291-
local.get $1
1292+
local.get $0
12921293
if
12931294
i32.const 0
12941295
i32.const 1040
@@ -1299,7 +1300,7 @@
12991300
end
13001301
i32.const 1
13011302
global.set $do/ran
1302-
local.get $1
1303+
local.get $0
13031304
call $~lib/rt/pure/__release
13041305
global.get $do/ran
13051306
i32.eqz
@@ -1313,44 +1314,42 @@
13131314
end
13141315
i32.const 0
13151316
global.set $do/ran
1316-
i32.const 0
1317-
local.set $2
13181317
call $~lib/rt/tlsf/maybeInitialize
13191318
call $~lib/rt/tlsf/allocateBlock
13201319
i32.const 16
13211320
i32.add
13221321
call $~lib/rt/pure/__retain
1323-
local.set $1
1324-
loop $do-continue|06
1322+
local.set $0
1323+
loop $do-continue|05
13251324
block $do-break|0
1326-
local.get $2
1325+
local.get $3
13271326
i32.const 1
13281327
i32.add
1329-
local.tee $2
1328+
local.tee $3
13301329
i32.const 10
13311330
i32.eq
13321331
if
1333-
local.get $1
1332+
local.get $0
13341333
if
1335-
local.get $1
1334+
local.get $0
13361335
call $~lib/rt/pure/__release
13371336
end
13381337
i32.const 0
1339-
local.set $1
1338+
local.set $0
13401339
br $do-break|0
13411340
end
13421341
call $~lib/rt/tlsf/maybeInitialize
13431342
call $~lib/rt/tlsf/allocateBlock
13441343
i32.const 16
13451344
i32.add
13461345
call $~lib/rt/pure/__retain
1347-
local.tee $0
1346+
local.tee $2
13481347
call $~lib/rt/pure/__release
1349-
local.get $0
1350-
br_if $do-continue|06
1348+
local.get $2
1349+
br_if $do-continue|05
13511350
end
13521351
end
1353-
local.get $2
1352+
local.get $3
13541353
i32.const 10
13551354
i32.ne
13561355
if
@@ -1361,7 +1360,7 @@
13611360
call $~lib/builtins/abort
13621361
unreachable
13631362
end
1364-
local.get $1
1363+
local.get $0
13651364
if
13661365
i32.const 0
13671366
i32.const 1040
@@ -1372,7 +1371,7 @@
13721371
end
13731372
i32.const 1
13741373
global.set $do/ran
1375-
local.get $1
1374+
local.get $0
13761375
call $~lib/rt/pure/__release
13771376
global.get $do/ran
13781377
i32.eqz

0 commit comments

Comments
 (0)