]> git.proxmox.com Git - rustc.git/blob - src/binaryen/test/passes/remove-unused-brs.wast
New upstream version 1.23.0+dfsg1
[rustc.git] / src / binaryen / test / passes / remove-unused-brs.wast
1 (module
2 (memory 256 256)
3 (type $0 (func (param i32)))
4 (type $1 (func))
5 (type $2 (func (result i32)))
6 (func $b0-yes (type $0) (param $i1 i32)
7 (block $topmost
8 (br $topmost)
9 )
10 )
11 (func $b1 (type $0) (param $i1 i32)
12 (block $topmost
13 (block
14 (drop
15 (i32.const 0)
16 )
17 (br $topmost)
18 )
19 )
20 )
21 (func $b2 (type $0) (param $i1 i32)
22 (block $topmost
23 (block $inner
24 (br $topmost)
25 )
26 )
27 )
28 (func $b3-yes (type $0) (param $i1 i32)
29 (block $topmost
30 (block $inner
31 (br $inner)
32 )
33 )
34 )
35 (func $b4 (type $0) (param $i1 i32)
36 (block $topmost
37 (block $inner
38 (block
39 (drop
40 (i32.const 0)
41 )
42 (br $topmost)
43 )
44 )
45 )
46 )
47 (func $b5 (type $0) (param $i1 i32)
48 (block $topmost
49 (block $inner
50 (block
51 (drop
52 (i32.const 0)
53 )
54 (br $inner)
55 )
56 )
57 )
58 )
59 (func $b6 (type $0) (param $i1 i32)
60 (block $topmost
61 (br_if $topmost
62 (i32.const 1)
63 )
64 )
65 )
66 (func $b7 (type $0) (param $i1 i32)
67 (block $topmost
68 (block
69 (drop
70 (i32.const 0)
71 )
72 (br_if $topmost
73 (i32.const 1)
74 )
75 )
76 )
77 )
78 (func $b8 (type $0) (param $i1 i32)
79 (block $topmost
80 (block $inner
81 (br_if $topmost
82 (i32.const 1)
83 )
84 )
85 )
86 )
87 (func $b9 (type $0) (param $i1 i32)
88 (block $topmost
89 (block $inner
90 (br_if $topmost
91 (i32.const 1)
92 )
93 )
94 )
95 )
96 (func $b10 (type $0) (param $i1 i32)
97 (block $topmost
98 (block $inner
99 (block
100 (drop
101 (i32.const 0)
102 )
103 (br_if $topmost
104 (i32.const 1)
105 )
106 )
107 )
108 )
109 )
110 (func $b11 (type $0) (param $i1 i32)
111 (block $topmost
112 (block $inner
113 (block
114 (drop
115 (i32.const 0)
116 )
117 (br_if $inner
118 (i32.const 1)
119 )
120 )
121 )
122 )
123 )
124 (func $b12-yes (type $1)
125 (block $topmost
126 (if
127 (i32.const 1)
128 (block $block1
129 (drop
130 (i32.const 12)
131 )
132 (block
133 (drop
134 (i32.const 1)
135 )
136 (br $topmost)
137 )
138 )
139 (block $block3
140 (drop
141 (i32.const 27)
142 )
143 (block
144 (drop
145 (i32.const 2)
146 )
147 (br $topmost)
148 )
149 )
150 )
151 )
152 )
153 (func $b13 (type $2) (result i32)
154 (block $topmost (result i32)
155 (if
156 (i32.const 1)
157 (block $block1
158 (drop
159 (i32.const 12)
160 )
161 (drop
162 (br_if $topmost
163 (i32.const 1)
164 (i32.const 1)
165 )
166 )
167 )
168 (block $block3
169 (drop
170 (i32.const 27)
171 )
172 (br $topmost
173 (i32.const 2)
174 )
175 )
176 )
177 (i32.const 3)
178 )
179 )
180 (func $b14 (type $2) (result i32)
181 (block $topmost (result i32)
182 (if (result i32)
183 (i32.const 1)
184 (block $block1 (result i32)
185 (i32.const 12)
186 )
187 (block $block3 (result i32)
188 (i32.const 27)
189 )
190 )
191 )
192 )
193 (func $b15 (type $1)
194 (block $topmost
195 (if
196 (i32.const 17)
197 (br $topmost)
198 )
199 )
200 )
201 (func $b15b (type $1)
202 (block $topmost
203 (if
204 (i32.const 18)
205 (block
206 (drop
207 (i32.const 0)
208 )
209 (br $topmost)
210 )
211 )
212 )
213 )
214 (func $b16 (type $1)
215 (block $a
216 (block $b
217 (block $c
218 (br $a)
219 )
220 (br $a)
221 )
222 (br $a)
223 )
224 (block $a
225 (block $b
226 (block $c
227 (br $c)
228 )
229 (br $b)
230 )
231 (br $a)
232 )
233 (block $a
234 (block $b
235 (block $c
236 (br $b)
237 )
238 (br $a)
239 )
240 (br $a)
241 )
242 )
243 (func $b17 (type $1)
244 (block $a
245 (if
246 (i32.const 0)
247 (block $block1
248 (br $a)
249 )
250 (block $block3
251 (br $a)
252 )
253 )
254 )
255 (block $a
256 (if
257 (i32.const 0)
258 (drop
259 (i32.const 1)
260 )
261 (block $block6
262 (br $a)
263 )
264 )
265 )
266 (block $a
267 (if
268 (i32.const 0)
269 (block $block8
270 (br $a)
271 )
272 (drop
273 (i32.const 1)
274 )
275 )
276 )
277 (block $c
278 (block $b
279 (if
280 (i32.const 0)
281 (block $block11
282 (br $b)
283 )
284 (block $block13
285 (br $c)
286 )
287 )
288 )
289 )
290 )
291 (func $ret-1 (type $1)
292 (return)
293 )
294 (func $ret-2 (type $1)
295 (block $block0
296 (block $block1
297 (return)
298 )
299 )
300 )
301 (func $ret-3 (type $1)
302 (block $block0
303 (if
304 (i32.const 0)
305 (return)
306 (block $block3
307 (return)
308 )
309 )
310 )
311 )
312 (func $ret-value (type $2) (result i32)
313 (block $block0
314 (block $block1
315 (return
316 (i32.const 1)
317 )
318 )
319 )
320 )
321 (func $no-select-but-the-last (type $1)
322 (block $a
323 (if
324 (i32.const 0)
325 (drop
326 (i32.const 1)
327 )
328 (block $block2
329 (block
330 (drop
331 (i32.const 2)
332 )
333 (br $a)
334 )
335 (drop
336 (i32.const 3)
337 )
338 )
339 )
340 (if
341 (i32.const 0)
342 (block $block4
343 (block
344 (drop
345 (i32.const 2)
346 )
347 (br $a)
348 )
349 (drop
350 (i32.const 3)
351 )
352 )
353 (drop
354 (i32.const 1)
355 )
356 )
357 (if
358 (block $block6 (result i32)
359 (block
360 (drop
361 (i32.const 2)
362 )
363 (br $a)
364 )
365 (i32.const 3)
366 )
367 (drop
368 (i32.const 0)
369 )
370 (drop
371 (i32.const 1)
372 )
373 )
374 (if
375 (block $a (result i32)
376 (br $a
377 (i32.const 0)
378 )
379 )
380 (block $a
381 (block
382 (drop
383 (i32.const 1)
384 )
385 (br $a)
386 )
387 )
388 (block $a
389 (block
390 (drop
391 (i32.const 2)
392 )
393 (br $a)
394 )
395 )
396 )
397 )
398 )
399 (func $side-effects-and-order (type $2) (result i32)
400 (local $x i32)
401 (block $do-once$0
402 (if
403 (call $b13)
404 (block
405 (drop
406 (i32.const 0)
407 )
408 (br $do-once$0)
409 )
410 )
411 (drop
412 (i32.const 1)
413 )
414 )
415 (block $do-once$0
416 (if
417 (call $b13)
418 (block
419 (drop
420 (call $b14)
421 )
422 (br $do-once$0)
423 )
424 )
425 (drop
426 (i32.const 1)
427 )
428 )
429 (block $do-once$0
430 (if
431 (i32.const 0)
432 (block
433 (drop
434 (call $b14)
435 )
436 (br $do-once$0)
437 )
438 )
439 (drop
440 (i32.const 1)
441 )
442 )
443 (block $do-once$0 (result i32)
444 (if
445 (tee_local $x
446 (i32.const 1)
447 )
448 (br $do-once$0
449 (tee_local $x
450 (i32.const 2)
451 )
452 )
453 )
454 (i32.const 1)
455 )
456 )
457 (func $loops
458 (loop $in
459 (block $out
460 (if (i32.const 0) (br $out))
461 (br $in) ;; we can conditionalize this, and then the br out can vanish
462 )
463 )
464 (loop $in
465 (br $in)
466 )
467 (loop
468 (block $out
469 (if (i32.const 0) (br $out))
470 (br $out)
471 )
472 )
473 (loop $in
474 (block $out
475 (if (i32.const 0) (br $out))
476 (br $out)
477 )
478 )
479 (loop $in)
480 (loop $in
481 (block $out)
482 )
483 (loop $in
484 (block $out
485 (if (i32.const 0) (br $out))
486 (br_if $in (i32.const 1))
487 )
488 )
489 (loop $in
490 (block $out
491 (if (i32.const 0) (br $in))
492 (br $out)
493 )
494 )
495 (loop $in
496 (block $out
497 (if (i32.const 0) (unreachable))
498 (br $in)
499 )
500 )
501 (loop $in
502 (block $out
503 (if (i32.const 0)
504 (block
505 (call $loops)
506 (br $out)
507 )
508 )
509 (br $in)
510 )
511 )
512 (loop $in-todo ;; br_if into if
513 (block $out-todo
514 (if (i32.const 0) (br $out-todo))
515 (call $loops)
516 (br $in-todo)
517 )
518 )
519 (loop $in
520 (block $out
521 (if (i32.const 0)
522 (br $out)
523 (call $loops)
524 )
525 (br $in)
526 )
527 )
528 (loop $in
529 (block $out
530 (if (i32.const 0)
531 (call $loops)
532 (br $out)
533 )
534 (br $in)
535 )
536 )
537 (loop $in
538 (block $out
539 (if (i32.const 0)
540 (block
541 (drop (i32.const 1))
542 (call $loops)
543 )
544 (br $out)
545 )
546 (br $in)
547 )
548 )
549 (loop $in
550 (block $out
551 (if (i32.const 0)
552 (br $out)
553 (call $loops)
554 )
555 (drop (i32.const 100))
556 (br $in)
557 )
558 )
559 (loop $in
560 (block $out
561 (if (i32.const 0)
562 (call $loops)
563 (br $out)
564 )
565 (drop (i32.const 101))
566 (br $in)
567 )
568 )
569 (loop $in
570 (block $out
571 (if (i32.const 0)
572 (block
573 (drop (i32.const 1))
574 (call $loops)
575 )
576 (br $out)
577 )
578 (drop (i32.const 102))
579 (br $in)
580 )
581 )
582 (loop $in
583 (block $out
584 (if (i32.const 0)
585 (br $out)
586 (call $loops)
587 )
588 (return)
589 (br $in)
590 )
591 )
592 (loop $in
593 (block $out
594 (if (i32.const 0)
595 (br $out)
596 (call $loops)
597 )
598 (br $out)
599 (br $in)
600 )
601 )
602 (loop $in
603 (block $out
604 (if (i32.const 0)
605 (br $out)
606 (call $loops)
607 )
608 (drop
609 (block $out2 (result i32)
610 (br $out2 (i32.const 1))
611 )
612 )
613 (br $in)
614 )
615 )
616 (loop $in
617 (block $out
618 (br_if $out (i32.const 0))
619 (br $in)
620 )
621 )
622 (loop $in-todo2 ;; if-ify
623 (block $out-todo2
624 (br_if $out-todo2 (i32.const 0))
625 (call $loops)
626 (br $in-todo2)
627 )
628 )
629 (loop $in
630 (block $out
631 (br $out)
632 (br $in)
633 )
634 )
635 (loop $in
636 (block $out
637 (br_if $in (i32.const 0))
638 (br $in)
639 )
640 )
641 (loop $in-not ;; do NOT if-ify, the block can't be removed
642 (block $out-not
643 (br_if $out-not (i32.const -1))
644 (br_if $out-not (i32.const 0))
645 (call $loops)
646 (br $in-not)
647 )
648 )
649 (loop $in-todo2 ;; if-ify a slice with 2 things
650 (block $out-todo2
651 (br_if $out-todo2 (i32.const 0))
652 (call $loops)
653 (drop (i32.const 1))
654 (br $in-todo2)
655 )
656 )
657 )
658 (func $br_if_in_block (result i32)
659 (block $outval (result i32)
660 (block $in
661 (if (i32.const 1) (br $in) (br $in))
662 (drop (i32.const 2))
663 (if (i32.const 3) (unreachable) (br $in))
664 (drop (i32.const 4))
665 (if (i32.const 5) (br $in) (unreachable))
666 (drop (i32.const 6))
667 )
668 (if (result i32) (i32.const 6) (br $outval (i32.const 7)) (i32.const 8))
669 )
670 )
671 (func $threading
672 (drop
673 (block $value-out (result i32)
674 (block $value-in (result i32)
675 (block $out
676 (block $in
677 (if (i32.const 1)
678 (br $in)
679 )
680 (br_if $in (i32.const 2))
681 (br $value-in (i32.const 3))
682 )
683 (br $out)
684 )
685 (i32.const 4)
686 )
687 )
688 )
689 (block $stack1
690 (block $stack2
691 (block $stack3
692 (block $stack4
693 (if (i32.const 1)
694 (br $stack4)
695 )
696 (unreachable)
697 )
698 (br $stack3)
699 )
700 (br $stack2)
701 )
702 (br $stack1)
703 )
704 )
705 (func $if-to-br_if-conflict (param $x i32) (param $y i32) (result i32)
706 (block $leave
707 (set_local $y
708 (block $out (result i32)
709 (if
710 (get_local $x)
711 (br $out
712 (block (result i32)
713 (set_local $x (i32.const 0))
714 (i32.const 1)
715 )
716 )
717 (br_if $leave (i32.const 1))
718 )
719 (unreachable)
720 )
721 )
722 )
723 (i32.add (get_local $x) (get_local $y))
724 )
725 (func $if-to-br_if-conflict2 (param $x i32) (param $y i32) (result i32)
726 (block $leave
727 (set_local $y
728 (block $out (result i32)
729 (if
730 (get_local $x)
731 (br_if $leave (i32.const 1))
732 (br $out
733 (block (result i32)
734 (set_local $x (i32.const 0))
735 (i32.const 1)
736 )
737 )
738 )
739 (unreachable)
740 )
741 )
742 )
743 (i32.add (get_local $x) (get_local $y))
744 )
745 (func $if-to-br_if-value-sideeffect (param $x i32) (param $y i32) (result i32)
746 (block $leave
747 (set_local $y
748 (block $out (result i32)
749 (if
750 (get_local $x)
751 (br $out
752 (block (result i32)
753 (drop (call $if-to-br_if-value-sideeffect (i32.const 0) (i32.const 1)))
754 (nop)
755 (i32.const 1)
756 )
757 )
758 )
759 (unreachable)
760 )
761 )
762 )
763 (i32.add (get_local $x) (get_local $y))
764 )
765 (func $fuzz (param $j i32) (param $g i32)
766 (block $label$break$c
767 (loop $label$continue$d
768 (block $label$break$d
769 (if
770 (i32.lt_s
771 (get_local $j)
772 (i32.const 2147483640)
773 )
774 (block $x
775 (block $y
776 (block $z
777 (br_if $y
778 (get_local $j)
779 )
780 (br $x) ;; don't be confused by this
781 )
782 (nop) ;; get me to the store!
783 )
784 )
785 (block $switch$26
786 (nop)
787 )
788 )
789 (i32.store
790 (i32.const 5724)
791 (i32.const -254899267)
792 )
793 (br $label$continue$d)
794 )
795 )
796 )
797 )
798 (func $iffify
799 (block $yes
800 (br_if $yes
801 (i32.const 0)
802 )
803 (drop (i32.const 1))
804 (drop (i32.const 2))
805 )
806 (block $no
807 (br_if $no
808 (i32.const 0)
809 )
810 (drop (i32.const 1))
811 (br $no)
812 (drop (i32.const 2))
813 )
814 (block $no2
815 (br_if $no2
816 (i32.const 0)
817 )
818 )
819 (block $no3
820 (br $no3)
821 (drop (i32.const 1))
822 (drop (i32.const 2))
823 )
824 (block $no5
825 (block $no4
826 (br_if $no5
827 (i32.const 0)
828 )
829 (drop (i32.const 1))
830 (drop (i32.const 2))
831 )
832 )
833 )
834 (func $loop-if (result i32)
835 (block $outer (result i32)
836 (loop $typed (result i32)
837 ;; we can move the br after us into our if-else, which means we are the final
838 ;; element in the block,
839 (if
840 (i32.const 2)
841 (block
842 (drop (call $loop-if))
843 (br $outer (i32.const 0))
844 )
845 )
846 (br $typed)
847 )
848 )
849 )
850 (func $block-break (param $0 i32)
851 (block $block$7$break
852 (block $shape$6$continue
853 (call $block-break (i32.const 1))
854 (br $block$7$break)
855 )
856 )
857 )
858 (func $loop-break (param $0 i32)
859 (block $block$7$break
860 (loop $shape$6$continue
861 (call $loop-break (i32.const 1))
862 (br_if $shape$6$continue
863 (get_local $0)
864 )
865 (br $block$7$break)
866 )
867 )
868 )
869 (func $untaken-brs-might-prevent-block-removal (param $0 f32) (param $1 i32) (param $2 f32) (param $3 i32) (param $4 i32) (param $5 f64) (param $6 f32) (result i32)
870 (block $label$0 (result i32)
871 (block $label$1 ;; this block has no taken brs, but we can't remove it without removing them first
872 (br_if $label$1
873 (i32.const 607395945)
874 )
875 (br_if $label$1
876 (i32.load16_s offset=3 align=1
877 (select
878 (call $untaken-brs-might-prevent-block-removal
879 (f32.const 1.4904844647389837e-07)
880 (br_if $label$0
881 (i32.store16 offset=4 align=1
882 (i32.const 1900641)
883 (br $label$0
884 (i32.const 1628075109)
885 )
886 )
887 (i32.const 1764950569)
888 )
889 (f32.const 1.1910939690100655e-32)
890 (i32.const 1628057906)
891 (i32.const 859068982)
892 (f64.const 2.524518840347722e-258)
893 (f32.const -nan:0x40a63)
894 )
895 (i32.const 688529440)
896 (i32.const 1751478890)
897 )
898 )
899 )
900 )
901 (i32.const 1935947830)
902 )
903 )
904 (func $unexitable-loops-result (param $0 i32) (result i64)
905 (loop $label$0
906 (loop $label$1
907 (if
908 (i32.load8_s
909 (i32.const 201460482)
910 )
911 (br $label$0)
912 (block $label$3
913 (br_if $label$3
914 (get_local $0)
915 )
916 )
917 )
918 (br $label$1)
919 )
920 )
921 )
922 (func $untaken-br-with-concrete-last-element
923 (block $label$8
924 (block $label$11
925 (block $label$14
926 (br_if $label$14
927 (br $label$11
928 )
929 )
930 )
931 )
932 )
933 )
934 (func $untaken-br-with-concrete-last-element2 (result i32)
935 (block $label$8 (result i32)
936 (block $label$11 (result i32)
937 (block $label$14 (result i32)
938 (br_if $label$14
939 (i32.const 102)
940 (br $label$11
941 (i32.const 103)
942 )
943 )
944 )
945 )
946 )
947 )
948 (func $untaken-br_if-then-if
949 (block $label$0
950 (br_if $label$0
951 (unreachable)
952 )
953 (if
954 (i32.const 0)
955 (nop)
956 )
957 )
958 )
959 (func $unreachable-if-that-could-be-a-br_if (result i64)
960 (loop $label$3 (result i64)
961 (drop
962 (if (result f64)
963 (unreachable)
964 (f64.const 1)
965 (br $label$3)
966 )
967 )
968 (i64.const 1)
969 )
970 )
971 (func $nop-br-might-update-type
972 (block $label$39
973 (drop
974 (if (result i32)
975 (unreachable)
976 (if (result i32)
977 (i32.const 1)
978 (br $label$39) ;; if we nop this, then the parent type must change
979 (i32.const 0)
980 )
981 (i32.const 0)
982 )
983 )
984 )
985 )
986 (func $no-flow-through-if-without-else (result f32)
987 (local $0 i32)
988 (local $2 f32)
989 (block $label$0
990 (if
991 (get_local $0)
992 (block $label$11
993 (return
994 (f32.const 239)
995 )
996 (if
997 (i32.const 0)
998 (return
999 (get_local $2)
1000 )
1001 )
1002 )
1003 (return
1004 (f32.const -9223372036854775808)
1005 )
1006 )
1007 )
1008 )
1009 (func $unreachable-return-loop-value (result i64)
1010 (loop $loop
1011 (if
1012 (i32.const 1)
1013 (block $block
1014 (br_if $block
1015 (br $loop)
1016 )
1017 (br $loop)
1018 )
1019 )
1020 (br $loop) ;; we 100% go back to the loop top, the loop is never exited. but opts move code around so that is not obvious anymore, and the loop becomes a nop, but the func has a return value
1021 )
1022 )
1023 (func $obviously-flows-out-maybe (param $var$0 i32) (result f32)
1024 (block $label$1 (result f32)
1025 (br $label$1
1026 (f32.const 1)
1027 )
1028 (loop $label$5
1029 (if
1030 (i32.const 11)
1031 (block $label$8 ;; this block is none - it has a break, even if not taken - and so looks like it might flow out,
1032 (br_if $label$8 ;; and so we can't move it outside to be the end of the loop's block
1033 (unreachable)
1034 )
1035 (br $label$5)
1036 )
1037 )
1038 (br $label$5)
1039 )
1040 )
1041 )
1042 )
1043