blob: 355999f6171f2aa44b77d0f577d442f11bb2a069 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.
;; RUN: foreach %s %t wasm-opt -all --gufa -S -o - | filecheck %s
(module
;; CHECK: (type $0 (func (param i32)))
;; CHECK: (export "test" (func $test))
;; CHECK: (func $test (type $0) (param $x i32)
;; CHECK-NEXT: (local $y i32)
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (local.get $x)
;; CHECK-NEXT: )
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (i32.const 0)
;; CHECK-NEXT: )
;; CHECK-NEXT: (local.set $x
;; CHECK-NEXT: (i32.const 10)
;; CHECK-NEXT: )
;; CHECK-NEXT: (local.set $y
;; CHECK-NEXT: (i32.const 20)
;; CHECK-NEXT: )
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (i32.const 10)
;; CHECK-NEXT: )
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (i32.const 20)
;; CHECK-NEXT: )
;; CHECK-NEXT: (local.set $x
;; CHECK-NEXT: (i32.const 30)
;; CHECK-NEXT: )
;; CHECK-NEXT: (local.set $y
;; CHECK-NEXT: (i32.const 40)
;; CHECK-NEXT: )
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (i32.const 30)
;; CHECK-NEXT: )
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (i32.const 40)
;; CHECK-NEXT: )
;; CHECK-NEXT: (if
;; CHECK-NEXT: (i32.const 30)
;; CHECK-NEXT: (then
;; CHECK-NEXT: (local.set $y
;; CHECK-NEXT: (i32.const 50)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (i32.const 30)
;; CHECK-NEXT: )
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (local.get $y)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $test (export "test") (param $x i32)
(local $y i32)
;; A parameter - nothing to optimize.
(drop
(local.get $x)
)
;; This has the default value, and can be optimized to 0.
(drop
(local.get $y)
)
(local.set $x
(i32.const 10)
)
(local.set $y
(i32.const 20)
)
;; These can both be optimized to constants, 10 and 20.
(drop
(local.get $x)
)
(drop
(local.get $y)
)
(local.set $x
(i32.const 30)
)
(local.set $y
(i32.const 40)
)
;; Now these are 30 and 40.
(drop
(local.get $x)
)
(drop
(local.get $y)
)
(if
(local.get $x)
(then
(local.set $y
(i32.const 50)
)
)
)
;; x is the same but y is no longer optimizable, since it might contain 50.
(drop
(local.get $x)
)
(drop
(local.get $y)
)
)
)
|