forked from WebAssembly/binaryen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flatten_rereloop.wast
179 lines (179 loc) · 2.64 KB
/
flatten_rereloop.wast
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
(module
(memory 1)
(global $global (mut i32) (i32.const 0))
(func $0 (result f64)
(if
(i32.const 0)
(loop $label$2
(unreachable)
)
)
(f64.const -nan:0xfffffd63e4e5a)
)
(func $1 (result i32)
(block $label$8
(block $label$9
(block $label$16
(block $label$18
(block $label$19
(br_table $label$18 $label$16 $label$19
(i32.const 0)
)
)
(br_table $label$9 $label$8
(i32.const 1)
)
)
(unreachable)
)
(unreachable)
)
(unreachable)
)
(i32.const 2)
)
(func $skip-empty
(block $a1
(block $a2
(block $a3
(block $a4
(br $a4)
)
(br $a3)
)
(br $a2)
)
(br $a1)
)
)
(func $skip-empty-2
(block $a1
(block $a2
(block $a3
(block $a4
(br $a4)
)
(call $skip-empty)
(br $a3)
)
(call $skip-empty)
(br $a2)
)
(br $a1)
)
)
(func $skip-empty-3
(block $a1
(block $a2
(block $a3
(block $a4
(nop)
(br $a4)
(nop)
)
(nop)
(call $skip-empty)
(nop)
(br $a3)
)
(nop)
(call $skip-empty)
(nop)
(br $a2)
)
(br $a1)
)
)
(func $skip-empty-4 (param $x i32)
(block $a1
(block $a2
(block $a3
(block $a4
(br_table $a1 $a2 $a3 $a4 $a1 $a2 $a3 $a4 (local.get $x))
)
(br $a3)
)
(br $a2)
)
(br $a1)
)
)
(func $skipping (param $0 i32) (result f32)
(if
(i32.const 0)
(unreachable)
) ;; branches joining here lead to skip opportunities
(loop $label$2 (result f32)
(f32.const 1)
)
)
(func $merging
(if
(i32.const 0)
(return)
;; no else, but the else ends up with a return too, and we can merge them
)
)
(func $unswitch
(block $label$1
(br_table $label$1 $label$1
(i32.const 0)
)
)
)
(func $skip-only-empty
(if
(i32.const 1)
(global.set $global
(i32.const 0)
)
)
)
(func $skip-only-one-branch-out (result i32)
(block $label$1
(nop)
)
(if
(i32.const 1)
(unreachable) ;; blocks a path through
)
(i32.const 0)
)
(func $multipass-for-skips (result f32)
(if (result f32)
(i32.const 0)
(block (result f32)
(block $label$2
(br_if $label$2
(i32.const 536870912)
)
)
(f32.const 9223372036854775808)
)
(f32.const 65505)
)
)
(func $branch-merge-vs-replace
(if
(i32.const 0)
(unreachable)
)
)
(func $unswitch-amount
(block $label$1
(if
(i32.const -23)
(nop)
(block
(block $label$4
(br_table $label$1 $label$4
(i32.const 44064)
)
)
(unreachable)
)
)
)
)
)
;; manual TODO: merge branches, all the parts