summaryrefslogtreecommitdiff
path: root/test/lit/passes/dae-gc-refine-return.wast
blob: 5e1f9d4e7f4b604867f09b1ec665179d7dc173b8 (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
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
;; NOTE: Assertions have been generated by update_lit_checks.py and should not be edited.
;; RUN: wasm-opt %s -all --dae -S -o - | filecheck %s

(module
 ;; CHECK:      (type $"{}" (sub (struct)))
 (type $"{}" (sub (struct)))

 ;; CHECK:      (type $"return_{}" (func (result (ref $"{}"))))
 (type $"return_{}" (func (result (ref $"{}"))))

 ;; CHECK:      (type $"{i32}" (sub $"{}" (struct (field i32))))
 (type $"{i32}" (sub $"{}" (struct (field i32))))

 ;; CHECK:      (type $"{i32_f32}" (sub $"{i32}" (struct (field i32) (field f32))))
 (type $"{i32_f32}" (sub $"{i32}" (struct (field i32) (field f32))))

 ;; CHECK:      (type $"{i32_i64}" (sub $"{i32}" (struct (field i32) (field i64))))
 (type $"{i32_i64}" (sub $"{i32}" (struct (field i32) (field i64))))

 (table 1 1 funcref)

 ;; We cannot refine the return type if nothing is actually returned.
 ;; CHECK:      (func $refine-return-no-return (type $0) (result anyref)
 ;; CHECK-NEXT:  (local $temp anyref)
 ;; CHECK-NEXT:  (local.set $temp
 ;; CHECK-NEXT:   (call $refine-return-no-return)
 ;; CHECK-NEXT:  )
 ;; CHECK-NEXT:  (unreachable)
 ;; CHECK-NEXT: )
 (func $refine-return-no-return (result anyref)
  ;; Call this function, so that we attempt to optimize it. Note that we do not
  ;; just drop the result, as that would cause the drop optimizations to kick
  ;; in.
  (local $temp anyref)
  (local.set $temp (call $refine-return-no-return))
  (unreachable)
 )

 ;; We cannot refine the return type if it is already the best it can be.
 ;; CHECK:      (func $refine-return-no-refining (type $0) (result anyref)
 ;; CHECK-NEXT:  (local $temp anyref)
 ;; CHECK-NEXT:  (local $any anyref)
 ;; CHECK-NEXT:  (local.set $temp
 ;; CHECK-NEXT:   (call $refine-return-no-refining)
 ;; CHECK-NEXT:  )
 ;; CHECK-NEXT:  (local.get $any)
 ;; CHECK-NEXT: )
 (func $refine-return-no-refining (result anyref)
  (local $temp anyref)
  (local $any anyref)

  (local.set $temp (call $refine-return-no-refining))

  (local.get $any)
 )

 ;; Refine the return type based on the value flowing out.
 ;; CHECK:      (func $refine-return-flow (type $4) (result i31ref)
 ;; CHECK-NEXT:  (local $temp anyref)
 ;; CHECK-NEXT:  (local $i31 i31ref)
 ;; CHECK-NEXT:  (local.set $temp
 ;; CHECK-NEXT:   (call $refine-return-flow)
 ;; CHECK-NEXT:  )
 ;; CHECK-NEXT:  (local.get $i31)
 ;; CHECK-NEXT: )
 (func $refine-return-flow (result anyref)
  (local $temp anyref)
  (local $i31 (ref null i31))

  (local.set $temp (call $refine-return-flow))

  (local.get $i31)
 )
 ;; CHECK:      (func $call-refine-return-flow (type $4) (result i31ref)
 ;; CHECK-NEXT:  (local $temp anyref)
 ;; CHECK-NEXT:  (local.set $temp
 ;; CHECK-NEXT:   (call $call-refine-return-flow)
 ;; CHECK-NEXT:  )
 ;; CHECK-NEXT:  (if (result i31ref)
 ;; CHECK-NEXT:   (i32.const 1)
 ;; CHECK-NEXT:   (then
 ;; CHECK-NEXT:    (call $refine-return-flow)
 ;; CHECK-NEXT:   )
 ;; CHECK-NEXT:   (else
 ;; CHECK-NEXT:    (call $refine-return-flow)
 ;; CHECK-NEXT:   )
 ;; CHECK-NEXT:  )
 ;; CHECK-NEXT: )
 (func $call-refine-return-flow (result anyref)
  (local $temp anyref)
  (local.set $temp (call $call-refine-return-flow))

  ;; After refining the return value of the above function, refinalize will
  ;; update types here, which will lead to updating the if, and then the entire
  ;; function's return value.
  (if (result anyref)
   (i32.const 1)
   (then
    (call $refine-return-flow)
   )
   (else
    (call $refine-return-flow)
   )
  )
 )

 ;; Refine the return type based on a return.
 ;; CHECK:      (func $refine-return-return (type $4) (result i31ref)
 ;; CHECK-NEXT:  (local $temp anyref)
 ;; CHECK-NEXT:  (local $i31 i31ref)
 ;; CHECK-NEXT:  (local.set $temp
 ;; CHECK-NEXT:   (call $refine-return-return)
 ;; CHECK-NEXT:  )
 ;; CHECK-NEXT:  (return
 ;; CHECK-NEXT:   (local.get $i31)
 ;; CHECK-NEXT:  )
 ;; CHECK-NEXT: )
 (func $refine-return-return (result anyref)
  (local $temp anyref)
  (local $i31 (ref null i31))

  (local.set $temp (call $refine-return-return))

  (return (local.get $i31))
 )

 ;; Refine the return type based on multiple values.
 ;; CHECK:      (func $refine-return-many (type $4) (result i31ref)
 ;; CHECK-NEXT:  (local $temp anyref)
 ;; CHECK-NEXT:  (local $i31 i31ref)
 ;; CHECK-NEXT:  (local.set $temp
 ;; CHECK-NEXT:   (call $refine-return-many)
 ;; CHECK-NEXT:  )
 ;; CHECK-NEXT:  (if
 ;; CHECK-NEXT:   (i32.const 1)
 ;; CHECK-NEXT:   (then
 ;; CHECK-NEXT:    (return
 ;; CHECK-NEXT:     (local.get $i31)
 ;; CHECK-NEXT:    )
 ;; CHECK-NEXT:   )
 ;; CHECK-NEXT:  )
 ;; CHECK-NEXT:  (if
 ;; CHECK-NEXT:   (i32.const 2)
 ;; CHECK-NEXT:   (then
 ;; CHECK-NEXT:    (return
 ;; CHECK-NEXT:     (local.get $i31)
 ;; CHECK-NEXT:    )
 ;; CHECK-NEXT:   )
 ;; CHECK-NEXT:  )
 ;; CHECK-NEXT:  (local.get $i31)
 ;; CHECK-NEXT: )
 (func $refine-return-many (result anyref)
  (local $temp anyref)
  (local $i31 (ref null i31))

  (local.set $temp (call $refine-return-many))

  (if
   (i32.const 1)
   (then
    (return (local.get $i31))
   )
  )
  (if
   (i32.const 2)
   (then
    (return (local.get $i31))
   )
  )
  (local.get $i31)
 )

 ;; CHECK:      (func $refine-return-many-lub (type $7) (result eqref)
 ;; CHECK-NEXT:  (local $temp anyref)
 ;; CHECK-NEXT:  (local $i31 i31ref)
 ;; CHECK-NEXT:  (local $struct structref)
 ;; CHECK-NEXT:  (local.set $temp
 ;; CHECK-NEXT:   (call $refine-return-many-lub)
 ;; CHECK-NEXT:  )
 ;; CHECK-NEXT:  (if
 ;; CHECK-NEXT:   (i32.const 1)
 ;; CHECK-NEXT:   (then
 ;; CHECK-NEXT:    (return
 ;; CHECK-NEXT:     (local.get $i31)
 ;; CHECK-NEXT:    )
 ;; CHECK-NEXT:   )
 ;; CHECK-NEXT:  )
 ;; CHECK-NEXT:  (if
 ;; CHECK-NEXT:   (i32.const 2)
 ;; CHECK-NEXT:   (then
 ;; CHECK-NEXT:    (return
 ;; CHECK-NEXT:     (local.get $struct)
 ;; CHECK-NEXT:    )
 ;; CHECK-NEXT:   )
 ;; CHECK-NEXT:  )
 ;; CHECK-NEXT:  (local.get $i31)
 ;; CHECK-NEXT: )
 (func $refine-return-many-lub (result anyref)
  (local $temp anyref)
  (local $i31 (ref null i31))
  (local $struct (ref null struct))

  (local.set $temp (call $refine-return-many-lub))

  (if
   (i32.const 1)
   (then
    (return (local.get $i31))
   )
  )
  (if
   (i32.const 2)
   ;; The refined return type has to be a supertype of struct.
   (then
    (return (local.get $struct))
   )
  )
  (local.get $i31)
 )

 ;; CHECK:      (func $refine-return-many-lub-2 (type $7) (result eqref)
 ;; CHECK-NEXT:  (local $temp anyref)
 ;; CHECK-NEXT:  (local $i31 i31ref)
 ;; CHECK-NEXT:  (local $struct structref)
 ;; CHECK-NEXT:  (local.set $temp
 ;; CHECK-NEXT:   (call $refine-return-many-lub-2)
 ;; CHECK-NEXT:  )
 ;; CHECK-NEXT:  (if
 ;; CHECK-NEXT:   (i32.const 1)
 ;; CHECK-NEXT:   (then
 ;; CHECK-NEXT:    (return
 ;; CHECK-NEXT:     (local.get $i31)
 ;; CHECK-NEXT:    )
 ;; CHECK-NEXT:   )
 ;; CHECK-NEXT:  )
 ;; CHECK-NEXT:  (if
 ;; CHECK-NEXT:   (i32.const 2)
 ;; CHECK-NEXT:   (then
 ;; CHECK-NEXT:    (return
 ;; CHECK-NEXT:     (local.get $i31)
 ;; CHECK-NEXT:    )
 ;; CHECK-NEXT:   )
 ;; CHECK-NEXT:  )
 ;; CHECK-NEXT:  (local.get $struct)
 ;; CHECK-NEXT: )
 (func $refine-return-many-lub-2 (result anyref)
  (local $temp anyref)
  (local $i31 (ref null i31))
  (local $struct (ref null struct))

  (local.set $temp (call $refine-return-many-lub-2))

  (if
   (i32.const 1)
   (then
    (return (local.get $i31))
   )
  )
  (if
   (i32.const 2)
   (then
    (return (local.get $i31))
   )
  )
  ;; The refined return type has to be a supertype of struct.
  (local.get $struct)
 )

 ;; We can refine the return types of tuples.
 ;; CHECK:      (func $refine-return-tuple (type $8) (result i31ref i32)
 ;; CHECK-NEXT:  (local $temp anyref)
 ;; CHECK-NEXT:  (local $i31 i31ref)
 ;; CHECK-NEXT:  (local.set $temp
 ;; CHECK-NEXT:   (tuple.extract 2 0
 ;; CHECK-NEXT:    (call $refine-return-tuple)
 ;; CHECK-NEXT:   )
 ;; CHECK-NEXT:  )
 ;; CHECK-NEXT:  (tuple.make 2
 ;; CHECK-NEXT:   (local.get $i31)
 ;; CHECK-NEXT:   (i32.const 1)
 ;; CHECK-NEXT:  )
 ;; CHECK-NEXT: )
 (func $refine-return-tuple (result anyref i32)
  (local $temp anyref)
  (local $i31 (ref null i31))

  (local.set $temp
   (tuple.extract 2 0
    (call $refine-return-tuple)
   )
  )

  (tuple.make 2
   (local.get $i31)
   (i32.const 1)
  )
 )

 ;; This function does a return call of the one after it. The one after it
 ;; returns a ref.func of this one. They both begin by returning a funcref;
 ;; after refining the return type of the second function, it will have a more
 ;; specific type (which is ok as subtyping is allowed with tail calls).
 ;; CHECK:      (func $do-return-call (type $6) (result funcref)
 ;; CHECK-NEXT:  (return_call $return-ref-func)
 ;; CHECK-NEXT: )
 (func $do-return-call (result funcref)
  (return_call $return-ref-func)
 )
 ;; CHECK:      (func $return-ref-func (type $9) (result (ref $6))
 ;; CHECK-NEXT:  (ref.func $do-return-call)
 ;; CHECK-NEXT: )
 (func $return-ref-func (result funcref)
  (ref.func $do-return-call)
 )

 ;; Show that we can optimize the return type of a function that does a tail
 ;; call.
 ;; CHECK:      (func $tail-callee (type $"return_{}") (result (ref $"{}"))
 ;; CHECK-NEXT:  (unreachable)
 ;; CHECK-NEXT: )
 (func $tail-callee (result (ref $"{}"))
  (unreachable)
 )
 ;; CHECK:      (func $tail-caller-yes (type $"return_{}") (result (ref $"{}"))
 ;; CHECK-NEXT:  (return_call $tail-callee)
 ;; CHECK-NEXT: )
 (func $tail-caller-yes (result anyref)
  ;; This function's return type can be refined because of this call, whose
  ;; target's return type is more specific than anyref.
  (return_call $tail-callee)
 )
 ;; CHECK:      (func $tail-caller-no (type $0) (result anyref)
 ;; CHECK-NEXT:  (local $any anyref)
 ;; CHECK-NEXT:  (if
 ;; CHECK-NEXT:   (i32.const 1)
 ;; CHECK-NEXT:   (then
 ;; CHECK-NEXT:    (return
 ;; CHECK-NEXT:     (local.get $any)
 ;; CHECK-NEXT:    )
 ;; CHECK-NEXT:   )
 ;; CHECK-NEXT:  )
 ;; CHECK-NEXT:  (return_call $tail-callee)
 ;; CHECK-NEXT: )
 (func $tail-caller-no (result anyref)
  (local $any anyref)

  ;; This function's return type cannot be refined because of another return
  ;; whose type prevents it.
  (if (i32.const 1)
   (then
    (return (local.get $any))
   )
  )
  (return_call $tail-callee)
 )
 ;; CHECK:      (func $tail-call-caller (type $5)
 ;; CHECK-NEXT:  (drop
 ;; CHECK-NEXT:   (call $tail-caller-yes)
 ;; CHECK-NEXT:  )
 ;; CHECK-NEXT:  (drop
 ;; CHECK-NEXT:   (call $tail-caller-no)
 ;; CHECK-NEXT:  )
 ;; CHECK-NEXT: )
 (func $tail-call-caller
  ;; Call the functions to cause optimization to happen.
  (drop
   (call $tail-caller-yes)
  )
  (drop
   (call $tail-caller-no)
  )
 )

 ;; As above, but with an indirect tail call.
 ;; CHECK:      (func $tail-callee-indirect (type $"return_{}") (result (ref $"{}"))
 ;; CHECK-NEXT:  (unreachable)
 ;; CHECK-NEXT: )
 (func $tail-callee-indirect (result (ref $"{}"))
  (unreachable)
 )
 ;; CHECK:      (func $tail-caller-indirect-yes (type $"return_{}") (result (ref $"{}"))
 ;; CHECK-NEXT:  (return_call_indirect $0 (type $"return_{}")
 ;; CHECK-NEXT:   (i32.const 0)
 ;; CHECK-NEXT:  )
 ;; CHECK-NEXT: )
 (func $tail-caller-indirect-yes (result anyref)
  (return_call_indirect (type $"return_{}") (i32.const 0))
 )
 ;; CHECK:      (func $tail-caller-indirect-no (type $0) (result anyref)
 ;; CHECK-NEXT:  (local $any anyref)
 ;; CHECK-NEXT:  (if
 ;; CHECK-NEXT:   (i32.const 1)
 ;; CHECK-NEXT:   (then
 ;; CHECK-NEXT:    (return
 ;; CHECK-NEXT:     (local.get $any)
 ;; CHECK-NEXT:    )
 ;; CHECK-NEXT:   )
 ;; CHECK-NEXT:  )
 ;; CHECK-NEXT:  (return_call_indirect $0 (type $"return_{}")
 ;; CHECK-NEXT:   (i32.const 0)
 ;; CHECK-NEXT:  )
 ;; CHECK-NEXT: )
 (func $tail-caller-indirect-no (result anyref)
  (local $any anyref)

  (if (i32.const 1)
   (then
    (return (local.get $any))
   )
  )
  (return_call_indirect (type $"return_{}") (i32.const 0))
 )
 ;; CHECK:      (func $tail-call-caller-indirect (type $5)
 ;; CHECK-NEXT:  (drop
 ;; CHECK-NEXT:   (call $tail-caller-indirect-yes)
 ;; CHECK-NEXT:  )
 ;; CHECK-NEXT:  (drop
 ;; CHECK-NEXT:   (call $tail-caller-indirect-no)
 ;; CHECK-NEXT:  )
 ;; CHECK-NEXT: )
 (func $tail-call-caller-indirect
  (drop
   (call $tail-caller-indirect-yes)
  )
  (drop
   (call $tail-caller-indirect-no)
  )
 )

 ;; As above, but with a tail call by function reference.
 ;; CHECK:      (func $tail-callee-call_ref (type $"return_{}") (result (ref $"{}"))
 ;; CHECK-NEXT:  (unreachable)
 ;; CHECK-NEXT: )
 (func $tail-callee-call_ref (result (ref $"{}"))
  (unreachable)
 )
 ;; CHECK:      (func $tail-caller-call_ref-yes (type $"return_{}") (result (ref $"{}"))
 ;; CHECK-NEXT:  (local $"return_{}" (ref null $"return_{}"))
 ;; CHECK-NEXT:  (return_call_ref $"return_{}"
 ;; CHECK-NEXT:   (local.get $"return_{}")
 ;; CHECK-NEXT:  )
 ;; CHECK-NEXT: )
 (func $tail-caller-call_ref-yes (result anyref)
  (local $"return_{}" (ref null $"return_{}"))

  (return_call_ref $"return_{}" (local.get $"return_{}"))
 )
 ;; CHECK:      (func $tail-caller-call_ref-no (type $0) (result anyref)
 ;; CHECK-NEXT:  (local $any anyref)
 ;; CHECK-NEXT:  (local $"return_{}" (ref null $"return_{}"))
 ;; CHECK-NEXT:  (if
 ;; CHECK-NEXT:   (i32.const 1)
 ;; CHECK-NEXT:   (then
 ;; CHECK-NEXT:    (return
 ;; CHECK-NEXT:     (local.get $any)
 ;; CHECK-NEXT:    )
 ;; CHECK-NEXT:   )
 ;; CHECK-NEXT:  )
 ;; CHECK-NEXT:  (return_call_ref $"return_{}"
 ;; CHECK-NEXT:   (local.get $"return_{}")
 ;; CHECK-NEXT:  )
 ;; CHECK-NEXT: )
 (func $tail-caller-call_ref-no (result anyref)
  (local $any anyref)
  (local $"return_{}" (ref null $"return_{}"))

  (if (i32.const 1)
   (then
    (return (local.get $any))
   )
  )
  (return_call_ref $"return_{}" (local.get $"return_{}"))
 )
 ;; CHECK:      (func $tail-caller-call_ref-unreachable (type $0) (result anyref)
 ;; CHECK-NEXT:  (block ;; (replaces unreachable CallRef we can't emit)
 ;; CHECK-NEXT:   (drop
 ;; CHECK-NEXT:    (unreachable)
 ;; CHECK-NEXT:   )
 ;; CHECK-NEXT:   (unreachable)
 ;; CHECK-NEXT:  )
 ;; CHECK-NEXT: )
 (func $tail-caller-call_ref-unreachable (result anyref)
  ;; An unreachable means there is no function signature to even look at. We
  ;; should not hit an assertion on such things.
  (return_call_ref $"return_{}" (unreachable))
 )
 ;; CHECK:      (func $tail-call-caller-call_ref (type $5)
 ;; CHECK-NEXT:  (drop
 ;; CHECK-NEXT:   (call $tail-caller-call_ref-yes)
 ;; CHECK-NEXT:  )
 ;; CHECK-NEXT:  (drop
 ;; CHECK-NEXT:   (call $tail-caller-call_ref-no)
 ;; CHECK-NEXT:  )
 ;; CHECK-NEXT:  (drop
 ;; CHECK-NEXT:   (call $tail-caller-call_ref-unreachable)
 ;; CHECK-NEXT:  )
 ;; CHECK-NEXT: )
 (func $tail-call-caller-call_ref
  (drop
   (call $tail-caller-call_ref-yes)
  )
  (drop
   (call $tail-caller-call_ref-no)
  )
  (drop
   (call $tail-caller-call_ref-unreachable)
  )
 )

 ;; CHECK:      (func $update-null (type $10) (param $x i32) (param $y i32) (result (ref null $"{i32}"))
 ;; CHECK-NEXT:  (if
 ;; CHECK-NEXT:   (local.get $x)
 ;; CHECK-NEXT:   (then
 ;; CHECK-NEXT:    (if
 ;; CHECK-NEXT:     (local.get $y)
 ;; CHECK-NEXT:     (then
 ;; CHECK-NEXT:      (return
 ;; CHECK-NEXT:       (struct.new_default $"{i32_f32}")
 ;; CHECK-NEXT:      )
 ;; CHECK-NEXT:     )
 ;; CHECK-NEXT:     (else
 ;; CHECK-NEXT:      (return
 ;; CHECK-NEXT:       (ref.null none)
 ;; CHECK-NEXT:      )
 ;; CHECK-NEXT:     )
 ;; CHECK-NEXT:    )
 ;; CHECK-NEXT:   )
 ;; CHECK-NEXT:   (else
 ;; CHECK-NEXT:    (return
 ;; CHECK-NEXT:     (struct.new_default $"{i32_i64}")
 ;; CHECK-NEXT:    )
 ;; CHECK-NEXT:   )
 ;; CHECK-NEXT:  )
 ;; CHECK-NEXT: )
 (func $update-null (param $x i32) (param $y i32) (result anyref)
  ;; Of the three returns here, the null can be updated, and the LUB is
  ;; determined by the other two, and is their shared parent $"{}."
  (if
   (local.get $x)
   (then
    (if
     (local.get $y)
     (then
      (return (struct.new_default $"{i32_f32}"))
     )
     (else
      (return (ref.null any))
     )
    )
   )
   (else
    (return (struct.new_default $"{i32_i64}"))
   )
  )
 )

 ;; CHECK:      (func $call-update-null (type $0) (result anyref)
 ;; CHECK-NEXT:  (drop
 ;; CHECK-NEXT:   (call $update-null
 ;; CHECK-NEXT:    (i32.const 0)
 ;; CHECK-NEXT:    (i32.const 1)
 ;; CHECK-NEXT:   )
 ;; CHECK-NEXT:  )
 ;; CHECK-NEXT:  (call $update-null
 ;; CHECK-NEXT:   (i32.const 1)
 ;; CHECK-NEXT:   (i32.const 0)
 ;; CHECK-NEXT:  )
 ;; CHECK-NEXT: )
 (func $call-update-null (result anyref)
  ;; Call $update-null so it gets optimized. (Call it with various values so
  ;; that other opts do not inline the constants.)
  (drop
   (call $update-null
    (i32.const 0)
    (i32.const 1)
   )
  )
  (call $update-null
   (i32.const 1)
   (i32.const 0)
  )
 )
)