Skip to content

Commit 6cba9a2

Browse files
committed
early glob optimization
1 parent 112160a commit 6cba9a2

37 files changed

+1324
-1311
lines changed

src/module.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1510,6 +1510,7 @@ export class Module {
15101510
passes.push("rse");
15111511
passes.push("vacuum");
15121512
passes.push("ssa-nomerge");
1513+
passes.push("simplify-globals-optimizing");
15131514
}
15141515
if (optimizeLevel >= 3) {
15151516
passes.push("flatten");

tests/compiler/comma.optimized.wat

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,6 @@
8080
global.set $comma/b
8181
i32.const 2
8282
global.set $comma/a
83-
global.get $comma/b
84-
i32.const 2
85-
i32.ne
86-
if
87-
i32.const 0
88-
i32.const 1040
89-
i32.const 19
90-
i32.const 1
91-
call $~lib/builtins/abort
92-
unreachable
93-
end
9483
loop $for-loop|0
9584
local.get $0
9685
global.get $comma/a

tests/compiler/do.optimized.wat

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,8 @@
688688
unreachable
689689
end
690690
i32.const 1216
691-
local.tee $1
691+
local.set $1
692+
i32.const 1216
692693
i32.const 0
693694
i32.store
694695
i32.const 2784
@@ -713,10 +714,10 @@
713714
i32.const 16
714715
i32.lt_u
715716
if
717+
local.get $2
716718
local.get $0
717719
i32.const 4
718720
i32.shl
719-
local.get $2
720721
i32.add
721722
i32.const 2
722723
i32.shl

tests/compiler/extends-baseaggregate.optimized.wat

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,8 @@
613613
unreachable
614614
end
615615
i32.const 1568
616-
local.tee $1
616+
local.set $1
617+
i32.const 1568
617618
i32.const 0
618619
i32.store
619620
i32.const 3136
@@ -638,10 +639,10 @@
638639
i32.const 16
639640
i32.lt_u
640641
if
642+
local.get $2
641643
local.get $0
642644
i32.const 4
643645
i32.shl
644-
local.get $2
645646
i32.add
646647
i32.const 2
647648
i32.shl
@@ -1379,10 +1380,10 @@
13791380
local.get $6
13801381
call $~lib/rt/tlsf/removeBlock
13811382
local.get $1
1383+
local.get $4
13821384
local.get $5
13831385
i32.const 3
13841386
i32.and
1385-
local.get $4
13861387
i32.or
13871388
i32.store
13881389
local.get $1
@@ -2106,14 +2107,11 @@
21062107
block $case3|0
21072108
block $case2|0
21082109
block $case1|0
2109-
local.get $1
2110-
i32.const 1
2111-
i32.ne
2112-
if
2110+
block $case0|0
21132111
local.get $1
2114-
i32.const 2
2112+
i32.const 1
21152113
i32.sub
2116-
br_table $case1|0 $case2|0 $case3|0 $case4|0 $case5|0
2114+
br_table $case0|0 $case1|0 $case2|0 $case3|0 $case4|0 $case5|0
21172115
end
21182116
local.get $0
21192117
call $~lib/rt/pure/decrement

tests/compiler/for.optimized.wat

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,8 @@
685685
unreachable
686686
end
687687
i32.const 1216
688-
local.tee $1
688+
local.set $1
689+
i32.const 1216
689690
i32.const 0
690691
i32.store
691692
i32.const 2784
@@ -710,10 +711,10 @@
710711
i32.const 16
711712
i32.lt_u
712713
if
714+
local.get $2
713715
local.get $0
714716
i32.const 4
715717
i32.shl
716-
local.get $2
717718
i32.add
718719
i32.const 2
719720
i32.shl

tests/compiler/implicit-getter-setter.optimized.wat

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,8 @@
620620
unreachable
621621
end
622622
i32.const 1232
623-
local.tee $1
623+
local.set $1
624+
i32.const 1232
624625
i32.const 0
625626
i32.store
626627
i32.const 2800
@@ -645,10 +646,10 @@
645646
i32.const 16
646647
i32.lt_u
647648
if
649+
local.get $2
648650
local.get $0
649651
i32.const 4
650652
i32.shl
651-
local.get $2
652653
i32.add
653654
i32.const 2
654655
i32.shl

tests/compiler/issues/1095.optimized.wat

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,8 @@
605605
unreachable
606606
end
607607
i32.const 1312
608-
local.tee $1
608+
local.set $1
609+
i32.const 1312
609610
i32.const 0
610611
i32.store
611612
i32.const 2880
@@ -630,10 +631,10 @@
630631
i32.const 16
631632
i32.lt_u
632633
if
634+
local.get $2
633635
local.get $0
634636
i32.const 4
635637
i32.shl
636-
local.get $2
637638
i32.add
638639
i32.const 2
639640
i32.shl

tests/compiler/issues/1225.optimized.wat

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,8 @@
606606
unreachable
607607
end
608608
i32.const 1232
609-
local.tee $1
609+
local.set $1
610+
i32.const 1232
610611
i32.const 0
611612
i32.store
612613
i32.const 2800
@@ -631,10 +632,10 @@
631632
i32.const 16
632633
i32.lt_u
633634
if
635+
local.get $2
634636
local.get $0
635637
i32.const 4
636638
i32.shl
637-
local.get $2
638639
i32.add
639640
i32.const 2
640641
i32.shl

tests/compiler/logical.optimized.wat

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,8 @@
603603
unreachable
604604
end
605605
i32.const 1232
606-
local.tee $1
606+
local.set $1
607+
i32.const 1232
607608
i32.const 0
608609
i32.store
609610
i32.const 2800
@@ -628,10 +629,10 @@
628629
i32.const 16
629630
i32.lt_u
630631
if
632+
local.get $2
631633
local.get $0
632634
i32.const 4
633635
i32.shl
634-
local.get $2
635636
i32.add
636637
i32.const 2
637638
i32.shl

tests/compiler/managed-cast.optimized.wat

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,8 @@
608608
unreachable
609609
end
610610
i32.const 1392
611-
local.tee $1
611+
local.set $1
612+
i32.const 1392
612613
i32.const 0
613614
i32.store
614615
i32.const 2960
@@ -633,10 +634,10 @@
633634
i32.const 16
634635
i32.lt_u
635636
if
637+
local.get $2
636638
local.get $0
637639
i32.const 4
638640
i32.shl
639-
local.get $2
640641
i32.add
641642
i32.const 2
642643
i32.shl

tests/compiler/object-literal.optimized.wat

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,8 @@
612612
unreachable
613613
end
614614
i32.const 1440
615-
local.tee $1
615+
local.set $1
616+
i32.const 1440
616617
i32.const 0
617618
i32.store
618619
i32.const 3008
@@ -637,10 +638,10 @@
637638
i32.const 16
638639
i32.lt_u
639640
if
641+
local.get $2
640642
local.get $0
641643
i32.const 4
642644
i32.shl
643-
local.get $2
644645
i32.add
645646
i32.const 2
646647
i32.shl

tests/compiler/rc/local-init.optimized.wat

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,8 @@
603603
unreachable
604604
end
605605
i32.const 1200
606-
local.tee $1
606+
local.set $1
607+
i32.const 1200
607608
i32.const 0
608609
i32.store
609610
i32.const 2768
@@ -628,10 +629,10 @@
628629
i32.const 16
629630
i32.lt_u
630631
if
632+
local.get $2
631633
local.get $0
632634
i32.const 4
633635
i32.shl
634-
local.get $2
635636
i32.add
636637
i32.const 2
637638
i32.shl

tests/compiler/rc/logical-and-mismatch.optimized.wat

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,8 @@
603603
unreachable
604604
end
605605
i32.const 1184
606-
local.tee $1
606+
local.set $1
607+
i32.const 1184
607608
i32.const 0
608609
i32.store
609610
i32.const 2752
@@ -628,10 +629,10 @@
628629
i32.const 16
629630
i32.lt_u
630631
if
632+
local.get $2
631633
local.get $0
632634
i32.const 4
633635
i32.shl
634-
local.get $2
635636
i32.add
636637
i32.const 2
637638
i32.shl

tests/compiler/rc/logical-or-mismatch.optimized.wat

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,8 @@
603603
unreachable
604604
end
605605
i32.const 1184
606-
local.tee $1
606+
local.set $1
607+
i32.const 1184
607608
i32.const 0
608609
i32.store
609610
i32.const 2752
@@ -628,10 +629,10 @@
628629
i32.const 16
629630
i32.lt_u
630631
if
632+
local.get $2
631633
local.get $0
632634
i32.const 4
633635
i32.shl
634-
local.get $2
635636
i32.add
636637
i32.const 2
637638
i32.shl

tests/compiler/rc/optimize.optimized.wat

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,8 @@
693693
unreachable
694694
end
695695
i32.const 1216
696-
local.tee $1
696+
local.set $1
697+
i32.const 1216
697698
i32.const 0
698699
i32.store
699700
i32.const 2784
@@ -718,10 +719,10 @@
718719
i32.const 16
719720
i32.lt_u
720721
if
722+
local.get $2
721723
local.get $0
722724
i32.const 4
723725
i32.shl
724-
local.get $2
725726
i32.add
726727
i32.const 2
727728
i32.shl

tests/compiler/rc/rereturn.optimized.wat

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,8 @@
606606
unreachable
607607
end
608608
i32.const 1232
609-
local.tee $1
609+
local.set $1
610+
i32.const 1232
610611
i32.const 0
611612
i32.store
612613
i32.const 2800
@@ -631,10 +632,10 @@
631632
i32.const 16
632633
i32.lt_u
633634
if
635+
local.get $2
634636
local.get $0
635637
i32.const 4
636638
i32.shl
637-
local.get $2
638639
i32.add
639640
i32.const 2
640641
i32.shl

tests/compiler/rc/ternary-mismatch.optimized.wat

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,8 @@
605605
unreachable
606606
end
607607
i32.const 1184
608-
local.tee $1
608+
local.set $1
609+
i32.const 1184
609610
i32.const 0
610611
i32.store
611612
i32.const 2752
@@ -630,10 +631,10 @@
630631
i32.const 16
631632
i32.lt_u
632633
if
634+
local.get $2
633635
local.get $0
634636
i32.const 4
635637
i32.shl
636-
local.get $2
637638
i32.add
638639
i32.const 2
639640
i32.shl

0 commit comments

Comments
 (0)