llvm.org GIT mirror llvm / 5b3a6d5
[WebAssembly] Disable MachineBlockPlacement pass Summary: This pass hurts code size for wasm and sometimes generates irreducible control flow. Context: https://github.com/emscripten-core/emscripten/pull/8233 Reviewers: kripken, dschuff Subscribers: sunfish, sbc100, jgravelle-google, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D58953 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@355437 91177308-0d34-0410-b5e6-96231b3b80d8 Heejin Ahn 7 months ago
7 changed file(s) with 77 addition(s) and 432 deletion(s). Raw diff Collapse all Expand all
289289 disablePass(&PatchableFunctionID);
290290 disablePass(&ShrinkWrapID);
291291
292 // This pass hurts code size for wasm because it can generate irreducible
293 // control flow.
294 disablePass(&MachineBlockPlacementID);
295
292296 TargetPassConfig::addPostRegAlloc();
293297 }
294298
0 ; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -disable-block-placement -verify-machineinstrs -fast-isel=false -machine-sink-split-probability-threshold=0 -cgp-freq-ratio-to-skip-merge=1000 | FileCheck %s
1 ; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -tail-dup-placement=0 -verify-machineinstrs -fast-isel=false -machine-sink-split-probability-threshold=0 -cgp-freq-ratio-to-skip-merge=1000 | FileCheck -check-prefix=OPT %s
21
32 ; Test the CFG stackifier pass.
43
2625 ; CHECK-NEXT: br
2726 ; CHECK-NEXT: .LBB0_4:
2827 ; CHECK-NEXT: end_loop
29 ; OPT-LABEL: test0:
30 ; OPT: loop
31 ; OPT: i32.ge_s
32 ; OPT-NEXT: br_if
33 ; OPT-NEXT: i32.const
34 ; OPT-NEXT: i32.add
35 ; OPT-NOT: br
36 ; OPT: call
37 ; OPT: br 0{{$}}
38 ; OPT: return{{$}}
3928 define void @test0(i32 %n) {
4029 entry:
4130 br label %header
7160 ; CHECK-NEXT: br
7261 ; CHECK-NEXT: .LBB1_4:
7362 ; CHECK-NEXT: end_loop
74 ; OPT-LABEL: test1:
75 ; OPT: loop
76 ; OPT: i32.ge_s
77 ; OPT-NEXT: br_if
78 ; OPT-NEXT: i32.const
79 ; OPT-NEXT: i32.add
80 ; OPT-NOT: br
81 ; OPT: call
82 ; OPT: br 0{{$}}
83 ; OPT: return{{$}}
8463 define void @test1(i32 %n) {
8564 entry:
8665 br label %header
11392 ; CHECK: end_loop
11493 ; CHECK: end_block
11594 ; CHECK: return{{$}}
116 ; OPT-LABEL: test2:
117 ; OPT-NOT: local
118 ; OPT: block {{$}}
119 ; OPT: br_if 0, {{[^,]+}}{{$}}
120 ; OPT: .LBB2_{{[0-9]+}}:
121 ; OPT: loop
122 ; OPT: br_if 0, $pop{{[0-9]+}}{{$}}
123 ; OPT: .LBB2_{{[0-9]+}}:
124 ; OPT: end_loop
125 ; OPT: end_block
126 ; OPT: return{{$}}
12795 define void @test2(double* nocapture %p, i32 %n) {
12896 entry:
12997 %cmp.4 = icmp sgt i32 %n, 0
165133 ; CHECK-NEXT: end_block{{$}}
166134 ; CHECK: i32.const $push{{[0-9]+}}=, 0{{$}}
167135 ; CHECK-NEXT: return $pop{{[0-9]+}}{{$}}
168 ; OPT-LABEL: doublediamond:
169 ; OPT: block {{$}}
170 ; OPT-NEXT: block {{$}}
171 ; OPT-NEXT: block {{$}}
172 ; OPT: br_if 0, ${{[^,]+}}{{$}}
173 ; OPT: br_if 1, ${{[^,]+}}{{$}}
174 ; OPT: br 2{{$}}
175 ; OPT-NEXT: .LBB3_3:
176 ; OPT-NEXT: end_block
177 ; OPT: br 1{{$}}
178 ; OPT-NEXT: .LBB3_4:
179 ; OPT: .LBB3_5:
180 ; OPT-NEXT: end_block
181 ; OPT: return $pop{{[0-9]+}}{{$}}
182136 define i32 @doublediamond(i32 %a, i32 %b, i32* %p) {
183137 entry:
184138 %c = icmp eq i32 %a, 0
207161 ; CHECK: br_if 0, $1{{$}}
208162 ; CHECK: .LBB4_2:
209163 ; CHECK: return
210 ; OPT-LABEL: triangle:
211 ; OPT: block {{$}}
212 ; OPT: br_if 0, $1{{$}}
213 ; OPT: .LBB4_2:
214 ; OPT: return
215164 define i32 @triangle(i32* %p, i32 %a) {
216165 entry:
217166 %c = icmp eq i32 %a, 0
234183 ; CHECK: .LBB5_3:
235184 ; CHECK: i32.const $push{{[0-9]+}}=, 0{{$}}
236185 ; CHECK-NEXT: return $pop{{[0-9]+}}{{$}}
237 ; OPT-LABEL: diamond:
238 ; OPT: block {{$}}
239 ; OPT: block {{$}}
240 ; OPT: br_if 0, {{[^,]+}}{{$}}
241 ; OPT: br 1{{$}}
242 ; OPT: .LBB5_2:
243 ; OPT: .LBB5_3:
244 ; OPT: i32.const $push{{[0-9]+}}=, 0{{$}}
245 ; OPT-NEXT: return $pop{{[0-9]+}}{{$}}
246186 define i32 @diamond(i32* %p, i32 %a) {
247187 entry:
248188 %c = icmp eq i32 %a, 0
262202 ; CHECK-LABEL: single_block:
263203 ; CHECK-NOT: br
264204 ; CHECK: return $pop{{[0-9]+}}{{$}}
265 ; OPT-LABEL: single_block:
266 ; OPT-NOT: br
267 ; OPT: return $pop{{[0-9]+}}{{$}}
268205 define i32 @single_block(i32* %p) {
269206 entry:
270207 store volatile i32 0, i32* %p
278215 ; CHECK: i32.store 0($0), $pop{{[0-9]+}}{{$}}
279216 ; CHECK: br 0{{$}}
280217 ; CHECK: .LBB7_2:
281 ; OPT-LABEL: minimal_loop:
282 ; OPT-NOT: br
283 ; OPT: .LBB7_1:
284 ; OPT: loop i32
285 ; OPT: i32.store 0($0), $pop{{[0-9]+}}{{$}}
286 ; OPT: br 0{{$}}
287 ; OPT: .LBB7_2:
288218 define i32 @minimal_loop(i32* %p) {
289219 entry:
290220 store volatile i32 0, i32* %p
302232 ; CHECK-NEXT: end_loop{{$}}
303233 ; CHECK: i32.const $push{{[0-9]+}}=, 0{{$}}
304234 ; CHECK-NEXT: return $pop{{[0-9]+}}{{$}}
305 ; OPT-LABEL: simple_loop:
306 ; OPT-NOT: br
307 ; OPT: .LBB8_1:
308 ; OPT: loop {{$}}
309 ; OPT: br_if 0, {{[^,]+}}{{$}}
310 ; OPT-NEXT: end_loop{{$}}
311 ; OPT: i32.const $push{{[0-9]+}}=, 0{{$}}
312 ; OPT-NEXT: return $pop{{[0-9]+}}{{$}}
313235 define i32 @simple_loop(i32* %p, i32 %a) {
314236 entry:
315237 %c = icmp eq i32 %a, 0
331253 ; CHECK: .LBB9_3:
332254 ; CHECK: .LBB9_4:
333255 ; CHECK: return
334 ; OPT-LABEL: doubletriangle:
335 ; OPT: block {{$}}
336 ; OPT: br_if 0, $0{{$}}
337 ; OPT: block {{$}}
338 ; OPT: br_if 0, $1{{$}}
339 ; OPT: .LBB9_3:
340 ; OPT: .LBB9_4:
341 ; OPT: return
342256 define i32 @doubletriangle(i32 %a, i32 %b, i32* %p) {
343257 entry:
344258 %c = icmp eq i32 %a, 0
369283 ; CHECK: .LBB10_4:
370284 ; CHECK: i32.const $push{{[0-9]+}}=, 0{{$}}
371285 ; CHECK-NEXT: return $pop{{[0-9]+}}{{$}}
372 ; OPT-LABEL: ifelse_earlyexits:
373 ; OPT: block {{$}}
374 ; OPT: block {{$}}
375 ; OPT: br_if 0, {{[^,]+}}{{$}}
376 ; OPT: br_if 1, $1{{$}}
377 ; OPT: br 1{{$}}
378 ; OPT: .LBB10_3:
379 ; OPT: .LBB10_4:
380 ; OPT: i32.const $push{{[0-9]+}}=, 0{{$}}
381 ; OPT-NEXT: return $pop{{[0-9]+}}{{$}}
382286 define i32 @ifelse_earlyexits(i32 %a, i32 %b, i32* %p) {
383287 entry:
384288 %c = icmp eq i32 %a, 0
414318 ; CHECK: br 0{{$}}
415319 ; CHECK: .LBB11_6:
416320 ; CHECK-NEXT: end_loop{{$}}
417 ; OPT-LABEL: doublediamond_in_a_loop:
418 ; OPT: .LBB11_1:
419 ; OPT: loop i32{{$}}
420 ; OPT: block {{$}}
421 ; OPT: br_if 0, {{[^,]+}}{{$}}
422 ; OPT: block {{$}}
423 ; OPT: br_if 0, {{[^,]+}}{{$}}
424 ; OPT: br 2{{$}}
425 ; OPT-NEXT: .LBB11_4:
426 ; OPT-NEXT: end_block{{$}}
427 ; OPT: br 1{{$}}
428 ; OPT: .LBB11_5:
429 ; OPT-NEXT: end_block{{$}}
430 ; OPT: br 0{{$}}
431 ; OPT: .LBB11_6:
432 ; OPT-NEXT: end_loop{{$}}
433321 define i32 @doublediamond_in_a_loop(i32 %a, i32 %b, i32* %p) {
434322 entry:
435323 br label %header
462350 ; CHECK-NEXT: br_if
463351 ; CHECK-NEXT: .LBB{{[0-9]+}}_{{[0-9]+}}:
464352 ; CHECK-NEXT: loop
465 ; OPT-LABEL: test3:
466 ; OPT: block
467 ; OPT: br_if
468 ; OPT: .LBB{{[0-9]+}}_{{[0-9]+}}:
469 ; OPT-NEXT: loop
470 ; OPT-NEXT: block
471 ; OPT-NEXT: block
472 ; OPT-NEXT: br_if
473 ; OPT-NEXT: .LBB{{[0-9]+}}_{{[0-9]+}}:
474 ; OPT-NEXT: loop
475 ; OPT: br_if
476 ; OPT-NEXT: br
477 ; OPT-NEXT: .LBB{{[0-9]+}}_{{[0-9]+}}:
478 ; OPT-NEXT: end_loop
479 ; OPT-NEXT: end_block
480 ; OPT-NEXT: unreachable
481 ; OPT-NEXT: .LBB{{[0-9]+}}_{{[0-9]+}}:
482 ; OPT-NEXT: end_block
483 ; OPT: br
484 ; OPT-NEXT: .LBB{{[0-9]+}}_{{[0-9]+}}:
485 ; OPT-NEXT: end_loop
486353 declare void @bar()
487354 define void @test3(i32 %w) {
488355 entry:
530397 ; CHECK-NEXT: .LBB13_6:
531398 ; CHECK-NEXT: end_block{{$}}
532399 ; CHECK-NEXT: return{{$}}
533 ; OPT-LABEL: test4:
534 ; OPT-NEXT: .functype test4 (i32) -> (){{$}}
535 ; OPT: block {{$}}
536 ; OPT-NEXT: block {{$}}
537 ; OPT: br_if 0, $pop{{[0-9]+}}{{$}}
538 ; OPT: br_if 1, $pop{{[0-9]+}}{{$}}
539 ; OPT: br 1{{$}}
540 ; OPT-NEXT: .LBB13_3:
541 ; OPT-NEXT: end_block{{$}}
542 ; OPT-NEXT: block {{$}}
543 ; OPT: br_if 0, $pop{{[0-9]+}}{{$}}
544 ; OPT: br_if 1, $pop{{[0-9]+}}{{$}}
545 ; OPT-NEXT: .LBB13_5:
546 ; OPT-NEXT: end_block{{$}}
547 ; OPT-NEXT: return{{$}}
548 ; OPT-NEXT: .LBB13_6:
549 ; OPT-NEXT: end_block{{$}}
550 ; OPT-NEXT: return{{$}}
551400 define void @test4(i32 %t) {
552401 entry:
553402 switch i32 %t, label %default [
583432 ; CHECK: return{{$}}
584433 ; CHECK-NEXT: .LBB14_4:
585434 ; CHECK: return{{$}}
586 ; OPT-LABEL: test5:
587 ; OPT: .LBB14_1:
588 ; OPT-NEXT: block {{$}}
589 ; OPT-NEXT: loop {{$}}
590 ; OPT: br_if 1, {{[^,]+}}{{$}}
591 ; OPT: br_if 0, {{[^,]+}}{{$}}
592 ; OPT-NEXT: end_loop{{$}}
593 ; OPT: return{{$}}
594 ; OPT-NEXT: .LBB14_4:
595 ; OPT: return{{$}}
596435 define void @test5(i1 %p, i1 %q) {
597436 entry:
598437 br label %header
639478 ; CHECK-NEXT: end_block{{$}}
640479 ; CHECK-NOT: block
641480 ; CHECK: return{{$}}
642 ; OPT-LABEL: test6:
643 ; OPT: .LBB15_1:
644 ; OPT-NEXT: block {{$}}
645 ; OPT-NEXT: block {{$}}
646 ; OPT-NEXT: loop {{$}}
647 ; OPT-NOT: block
648 ; OPT: br_if 2, {{[^,]+}}{{$}}
649 ; OPT-NOT: block
650 ; OPT: br_if 1, {{[^,]+}}{{$}}
651 ; OPT-NOT: block
652 ; OPT: br_if 0, {{[^,]+}}{{$}}
653 ; OPT-NEXT: end_loop{{$}}
654 ; OPT-NOT: block
655 ; OPT: return{{$}}
656 ; OPT-NEXT: .LBB15_5:
657 ; OPT-NEXT: end_block{{$}}
658 ; OPT-NOT: block
659 ; OPT: .LBB15_6:
660 ; OPT-NEXT: end_block{{$}}
661 ; OPT-NOT: block
662 ; OPT: return{{$}}
663481 define void @test6(i1 %p, i1 %q) {
664482 entry:
665483 br label %header
709527 ; CHECK-NEXT: end_loop{{$}}
710528 ; CHECK-NOT: block
711529 ; CHECK: unreachable
712 ; OPT-LABEL: test7:
713 ; OPT: .LBB16_1:
714 ; OPT-NEXT: block
715 ; OPT-NEXT: loop {{$}}
716 ; OPT-NOT: block
717 ; OPT: block {{$}}
718 ; OPT-NOT: block
719 ; OPT: br_if 0, {{[^,]+}}{{$}}
720 ; OPT-NOT: block
721 ; OPT: br_if 1, {{[^,]+}}{{$}}
722 ; OPT: br 2{{$}}
723 ; OPT-NEXT: .LBB16_3:
724 ; OPT-NEXT: end_block
725 ; OPT-NOT: block
726 ; OPT: br_if 0, {{[^,]+}}{{$}}
727 ; OPT-NEXT: end_loop
728 ; OPT-NOT: block
729 ; OPT: unreachable
730 ; OPT-NEXT: .LBB16_5:
731 ; OPT-NEXT: end_block
732 ; OPT-NOT: block
733 ; OPT: unreachable
734530 define void @test7(i1 %tobool2, i1 %tobool9) {
735531 entry:
736532 store volatile i32 0, i32* null
767563 ; CHECK-NEXT: br 0{{$}}
768564 ; CHECK-NEXT: .LBB17_2:
769565 ; CHECK-NEXT: end_loop{{$}}
770 ; OPT-LABEL: test8:
771 ; OPT: .LBB17_1:
772 ; OPT-NEXT: loop i32{{$}}
773 ; OPT-NEXT: i32.const $push{{[^,]+}}, 0{{$}}
774 ; OPT-NEXT: br_if 0, {{[^,]+}}{{$}}
775 ; OPT-NEXT: br 0{{$}}
776 ; OPT-NEXT: .LBB17_2:
777 ; OPT-NEXT: end_loop{{$}}
778566 define i32 @test8() {
779567 bb:
780568 br label %bb1
820608 ; CHECK: end_block
821609 ; CHECK-NOT: block
822610 ; CHECK: return{{$}}
823 ; OPT-LABEL: test9:
824 ; OPT: .LBB18_1:
825 ; OPT-NEXT: block {{$}}
826 ; OPT-NEXT: loop {{$}}
827 ; OPT-NOT: block
828 ; OPT: br_if 1, {{[^,]+}}{{$}}
829 ; OPT-NEXT: .LBB18_2:
830 ; OPT-NEXT: loop {{$}}
831 ; OPT-NOT: block
832 ; OPT: block {{$}}
833 ; OPT-NOT: block
834 ; OPT: br_if 0, {{[^,]+}}{{$}}
835 ; OPT-NOT: block
836 ; OPT: br_if 1, {{[^,]+}}{{$}}
837 ; OPT-NEXT: br 2{{$}}
838 ; OPT-NEXT: .LBB18_4:
839 ; OPT-NEXT: end_block{{$}}
840 ; OPT-NOT: block
841 ; OPT: br_if 0, {{[^,]+}}{{$}}
842 ; OPT-NEXT: br 1{{$}}
843 ; OPT-NEXT: .LBB18_5:
844 ; OPT-NOT: block
845 ; OPT: end_block
846 ; OPT-NOT: block
847 ; OPT: return{{$}}
848611 declare i1 @a()
849612 define void @test9() {
850613 entry:
905668 ; CHECK-NOT: block
906669 ; CHECK: br 0{{$}}
907670 ; CHECK-NEXT: .LBB19_10:
908 ; OPT-LABEL: test10:
909 ; OPT: .LBB19_1:
910 ; OPT-NEXT: loop {{$}}
911 ; OPT-NOT: block
912 ; OPT: br_if 0, {{[^,]+}}{{$}}
913 ; OPT: .LBB19_3:
914 ; OPT-NEXT: block {{$}}
915 ; OPT-NEXT: loop {{$}}
916 ; OPT-NOT: block
917 ; OPT: .LBB19_4:
918 ; OPT-NEXT: loop {{$}}
919 ; OPT-NOT: block
920 ; OPT: br_if 0, {{[^,]+}}{{$}}
921 ; OPT-NEXT: end_loop{{$}}
922 ; OPT: br_if 1, {{[^,]+}}{{$}}
923 ; OPT-NOT: block
924 ; OPT: br_if 0, {{[^,]+}}{{$}}
925 ; OPT-NEXT: end_loop{{$}}
926 ; OPT-NOT: block
927 ; OPT: br_if 1, {{[^,]+}}{{$}}
928 ; OPT-NEXT: return{{$}}
929 ; OPT-NEXT: .LBB19_9:
930 ; OPT-NEXT: end_block{{$}}
931 ; OPT-NOT: block
932 ; OPT: br 0{{$}}
933 ; OPT-NEXT: .LBB19_10:
934671 define void @test10() {
935672 bb0:
936673 br label %bb1
1002739 ; CHECK-NEXT: end_block{{$}}
1003740 ; CHECK-NOT: block
1004741 ; CHECK: return{{$}}
1005 ; OPT-LABEL: test11:
1006 ; OPT: block {{$}}
1007 ; OPT-NEXT: block {{$}}
1008 ; OPT: br_if 0, $pop{{[0-9]+}}{{$}}
1009 ; OPT-NOT: block
1010 ; OPT: block {{$}}
1011 ; OPT-NEXT: i32.const
1012 ; OPT-NEXT: br_if 0, {{[^,]+}}{{$}}
1013 ; OPT-NOT: block
1014 ; OPT: br_if 2, {{[^,]+}}{{$}}
1015 ; OPT-NEXT: .LBB20_3:
1016 ; OPT-NEXT: end_block{{$}}
1017 ; OPT-NOT: block
1018 ; OPT: return{{$}}
1019 ; OPT-NEXT: .LBB20_4:
1020 ; OPT-NEXT: end_block{{$}}
1021 ; OPT-NOT: block
1022 ; OPT: block {{$}}
1023 ; OPT-NOT: block
1024 ; OPT: br_if 0, $pop{{[0-9]+}}{{$}}
1025 ; OPT-NOT: block
1026 ; OPT: return{{$}}
1027 ; OPT-NEXT: .LBB20_6:
1028 ; OPT-NEXT: end_block{{$}}
1029 ; OPT-NOT: block
1030 ; OPT: br_if 0, $pop{{[0-9]+}}{{$}}
1031 ; OPT-NOT: block
1032 ; OPT: return{{$}}
1033 ; OPT-NEXT: .LBB20_8:
1034 ; OPT-NEXT: end_block{{$}}
1035 ; OPT-NOT: block
1036 ; OPT: return{{$}}
1037742 define void @test11() {
1038743 bb0:
1039744 store volatile i32 0, i32* null
1091796 ; CHECK-NEXT: end_loop{{$}}
1092797 ; CHECK-NEXT: end_block{{$}}
1093798 ; CHECK-NEXT: return{{$}}
1094 ; OPT-LABEL: test12:
1095 ; OPT: .LBB21_1:
1096 ; OPT-NEXT: block {{$}}
1097 ; OPT-NEXT: loop {{$}}
1098 ; OPT-NOT: block
1099 ; OPT: block {{$}}
1100 ; OPT-NEXT: block {{$}}
1101 ; OPT: br_if 0, {{[^,]+}}{{$}}
1102 ; OPT-NOT: block
1103 ; OPT: br_if 1, {{[^,]+}}{{$}}
1104 ; OPT-NOT: block
1105 ; OPT: br_if 1, {{[^,]+}}{{$}}
1106 ; OPT-NEXT: br 3{{$}}
1107 ; OPT-NEXT: .LBB21_4:
1108 ; OPT-NEXT: end_block{{$}}
1109 ; OPT-NOT: block
1110 ; OPT: br_if 0, {{[^,]+}}{{$}}
1111 ; OPT-NOT: block
1112 ; OPT: br_if 2, {{[^,]+}}{{$}}
1113 ; OPT-NEXT: .LBB21_6:
1114 ; OPT-NEXT: end_block{{$}}
1115 ; OPT: br 0{{$}}
1116 ; OPT-NEXT: .LBB21_7:
1117 ; OPT-NEXT: end_loop{{$}}
1118 ; OPT-NEXT: end_block{{$}}
1119 ; OPT-NEXT: return{{$}}
1120799 define void @test12(i8* %arg) {
1121800 bb:
1122801 br label %bb1
1160839 ; CHECK-NEXT: .LBB22_5:
1161840 ; CHECK-NEXT: end_block{{$}}
1162841 ; CHECK-NEXT: unreachable{{$}}
1163 ; OPT-LABEL: test13:
1164 ; OPT: block {{$}}
1165 ; OPT-NEXT: block {{$}}
1166 ; OPT: br_if 0, $pop0{{$}}
1167 ; OPT: block {{$}}
1168 ; OPT: br_if 0, $pop3{{$}}
1169 ; OPT: .LBB22_3:
1170 ; OPT-NEXT: end_block{{$}}
1171 ; OPT: br_if 1, $pop{{[0-9]+}}{{$}}
1172 ; OPT-NEXT: br 1{{$}}
1173 ; OPT-NEXT: .LBB22_4:
1174 ; OPT-NEXT: end_block
1175 ; OPT-NEXT: return
1176 ; OPT-NEXT: .LBB22_5:
1177 ; OPT-NEXT: end_block{{$}}
1178 ; OPT-NEXT: unreachable{{$}}
1179842 define void @test13() noinline optnone {
1180843 bb:
1181844 br i1 undef, label %bb5, label %bb2
1279942 ; CHECK: .LBB24_8:
1280943 ; CHECK-NEXT: end_block{{$}}
1281944 ; CHECK-NEXT: return{{$}}
1282 ; OPT-LABEL: test15:
1283 ; OPT: block
1284 ; OPT: block
1285 ; OPT-NEXT: i32.const $push
1286 ; OPT-NEXT: i32.eqz $push{{.*}}=, $pop{{.*}}{{$}}
1287 ; OPT-NEXT: br_if 0, $pop{{.*}}{{$}}
1288 ; OPT-NEXT: call test15_callee1{{$}}
1289 ; OPT-NEXT: br 1{{$}}
1290 ; OPT-NEXT: .LBB24_2:
1291 ; OPT-NEXT: end_block
1292 ; OPT-NEXT: i32.const
1293 ; OPT-NEXT: .LBB24_3:
1294 ; OPT-NEXT: block
1295 ; OPT-NEXT: block
1296 ; OPT-NEXT: loop
1297945 %0 = type { i8, i32 }
1298946 declare void @test15_callee0()
1299947 declare void @test15_callee1()
1111 ; CHECK-NEXT: f32.abs $push[[ABS:[0-9]+]]=, $0{{$}}
1212 ; CHECK-NEXT: f32.const $push[[LIMIT:[0-9]+]]=, 0x1p31{{$}}
1313 ; CHECK-NEXT: f32.lt $push[[LT:[0-9]+]]=, $pop[[ABS]], $pop[[LIMIT]]{{$}}
14 ; CHECK-NEXT: br_if 0, $pop[[LT]]{{$}}
14 ; CHECK-NEXT: i32.eqz $push[[EQZ:[0-9]+]]=, $pop[[LT]]
15 ; CHECK-NEXT: br_if 0, $pop[[EQZ]]{{$}}
16 ; CHECK-NEXT: i32.trunc_f32_s $push[[NUM:[0-9]+]]=, $0{{$}}
17 ; CHECK-NEXT: return $pop[[NUM]]{{$}}
18 ; CHECK-NEXT: BB
19 ; CHECK-NEXT: end_block
1520 ; CHECK-NEXT: i32.const $push[[ALT:[0-9]+]]=, -2147483648{{$}}
1621 ; CHECK-NEXT: return $pop[[ALT]]{{$}}
17 ; CHECK-NEXT: BB
18 ; CHECK-NEXT: end_block
19 ; CHECK-NEXT: i32.trunc_f32_s $push[[NUM:[0-9]+]]=, $0{{$}}
20 ; CHECK-NEXT: return $pop[[NUM]]{{$}}
2122 define i32 @i32_trunc_s_f32(float %x) {
2223 %a = fptosi float %x to i32
2324 ret i32 %a
3132 ; CHECK-NEXT: f32.const $push[[ZERO:[0-9]+]]=, 0x0p0{{$}}
3233 ; CHECK-NEXT: f32.ge $push[[GE:[0-9]+]]=, $0, $pop[[ZERO]]{{$}}
3334 ; CHECK-NEXT: i32.and $push[[AND:[0-9]+]]=, $pop[[LT]], $pop[[GE]]{{$}}
34 ; CHECK-NEXT: br_if 0, $pop[[AND]]{{$}}
35 ; CHECK-NEXT: i32.eqz $push[[EQZ:[0-9]+]]=, $pop[[AND]]
36 ; CHECK-NEXT: br_if 0, $pop[[EQZ]]{{$}}
37 ; CHECK-NEXT: i32.trunc_f32_u $push[[NUM:[0-9]+]]=, $0{{$}}
38 ; CHECK-NEXT: return $pop[[NUM]]{{$}}
39 ; CHECK-NEXT: BB
40 ; CHECK-NEXT: end_block
3541 ; CHECK-NEXT: i32.const $push[[ALT:[0-9]+]]=, 0{{$}}
3642 ; CHECK-NEXT: return $pop[[ALT]]{{$}}
37 ; CHECK-NEXT: BB
38 ; CHECK-NEXT: end_block
39 ; CHECK-NEXT: i32.trunc_f32_u $push[[NUM:[0-9]+]]=, $0{{$}}
40 ; CHECK-NEXT: return $pop[[NUM]]{{$}}
4143 define i32 @i32_trunc_u_f32(float %x) {
4244 %a = fptoui float %x to i32
4345 ret i32 %a
4951 ; CHECK-NEXT: f64.abs $push[[ABS:[0-9]+]]=, $0{{$}}
5052 ; CHECK-NEXT: f64.const $push[[LIMIT:[0-9]+]]=, 0x1p31{{$}}
5153 ; CHECK-NEXT: f64.lt $push[[LT:[0-9]+]]=, $pop[[ABS]], $pop[[LIMIT]]{{$}}
52 ; CHECK-NEXT: br_if 0, $pop[[LT]]{{$}}
54 ; CHECK-NEXT: i32.eqz $push[[EQZ:[0-9]+]]=, $pop[[LT]]
55 ; CHECK-NEXT: br_if 0, $pop[[EQZ]]{{$}}
56 ; CHECK-NEXT: i32.trunc_f64_s $push[[NUM:[0-9]+]]=, $0{{$}}
57 ; CHECK-NEXT: return $pop[[NUM]]{{$}}
58 ; CHECK-NEXT: BB
59 ; CHECK-NEXT: end_block
5360 ; CHECK-NEXT: i32.const $push[[ALT:[0-9]+]]=, -2147483648{{$}}
5461 ; CHECK-NEXT: return $pop[[ALT]]{{$}}
55 ; CHECK-NEXT: BB
56 ; CHECK-NEXT: end_block
57 ; CHECK-NEXT: i32.trunc_f64_s $push[[NUM:[0-9]+]]=, $0{{$}}
58 ; CHECK-NEXT: return $pop[[NUM]]{{$}}
5962 define i32 @i32_trunc_s_f64(double %x) {
6063 %a = fptosi double %x to i32
6164 ret i32 %a
6972 ; CHECK-NEXT: f64.const $push[[ZERO:[0-9]+]]=, 0x0p0{{$}}
7073 ; CHECK-NEXT: f64.ge $push[[GE:[0-9]+]]=, $0, $pop[[ZERO]]{{$}}
7174 ; CHECK-NEXT: i32.and $push[[AND:[0-9]+]]=, $pop[[LT]], $pop[[GE]]{{$}}
72 ; CHECK-NEXT: br_if 0, $pop[[AND]]{{$}}
75 ; CHECK-NEXT: i32.eqz $push[[EQZ:[0-9]+]]=, $pop[[AND]]
76 ; CHECK-NEXT: br_if 0, $pop[[EQZ]]{{$}}
77 ; CHECK-NEXT: i32.trunc_f64_u $push[[NUM:[0-9]+]]=, $0{{$}}
78 ; CHECK-NEXT: return $pop[[NUM]]{{$}}
79 ; CHECK-NEXT: BB
80 ; CHECK-NEXT: end_block
7381 ; CHECK-NEXT: i32.const $push[[ALT:[0-9]+]]=, 0{{$}}
7482 ; CHECK-NEXT: return $pop[[ALT]]{{$}}
75 ; CHECK-NEXT: BB
76 ; CHECK-NEXT: end_block
77 ; CHECK-NEXT: i32.trunc_f64_u $push[[NUM:[0-9]+]]=, $0{{$}}
78 ; CHECK-NEXT: return $pop[[NUM]]{{$}}
7983 define i32 @i32_trunc_u_f64(double %x) {
8084 %a = fptoui double %x to i32
8185 ret i32 %a
8791 ; CHECK-NEXT: f32.abs $push[[ABS:[0-9]+]]=, $0{{$}}
8892 ; CHECK-NEXT: f32.const $push[[LIMIT:[0-9]+]]=, 0x1p63{{$}}
8993 ; CHECK-NEXT: f32.lt $push[[LT:[0-9]+]]=, $pop[[ABS]], $pop[[LIMIT]]{{$}}
90 ; CHECK-NEXT: br_if 0, $pop[[LT]]{{$}}
94 ; CHECK-NEXT: i32.eqz $push[[EQZ:[0-9]+]]=, $pop[[LT]]
95 ; CHECK-NEXT: br_if 0, $pop[[EQZ]]{{$}}
96 ; CHECK-NEXT: i64.trunc_f32_s $push[[NUM:[0-9]+]]=, $0{{$}}
97 ; CHECK-NEXT: return $pop[[NUM]]{{$}}
98 ; CHECK-NEXT: BB
99 ; CHECK-NEXT: end_block
91100 ; CHECK-NEXT: i64.const $push[[ALT:[0-9]+]]=, -9223372036854775808{{$}}
92101 ; CHECK-NEXT: return $pop[[ALT]]{{$}}
93 ; CHECK-NEXT: BB
94 ; CHECK-NEXT: end_block
95 ; CHECK-NEXT: i64.trunc_f32_s $push[[NUM:[0-9]+]]=, $0{{$}}
96 ; CHECK-NEXT: return $pop[[NUM]]{{$}}
97102 define i64 @i64_trunc_s_f32(float %x) {
98103 %a = fptosi float %x to i64
99104 ret i64 %a
107112 ; CHECK-NEXT: f32.const $push[[ZERO:[0-9]+]]=, 0x0p0{{$}}
108113 ; CHECK-NEXT: f32.ge $push[[GE:[0-9]+]]=, $0, $pop[[ZERO]]{{$}}
109114 ; CHECK-NEXT: i32.and $push[[AND:[0-9]+]]=, $pop[[LT]], $pop[[GE]]{{$}}
110 ; CHECK-NEXT: br_if 0, $pop[[AND]]{{$}}
115 ; CHECK-NEXT: i32.eqz $push[[EQZ:[0-9]+]]=, $pop[[AND]]
116 ; CHECK-NEXT: br_if 0, $pop[[EQZ]]{{$}}
117 ; CHECK-NEXT: i64.trunc_f32_u $push[[NUM:[0-9]+]]=, $0{{$}}
118 ; CHECK-NEXT: return $pop[[NUM]]{{$}}
119 ; CHECK-NEXT: BB
120 ; CHECK-NEXT: end_block
111121 ; CHECK-NEXT: i64.const $push[[ALT:[0-9]+]]=, 0{{$}}
112122 ; CHECK-NEXT: return $pop[[ALT]]{{$}}
113 ; CHECK-NEXT: BB
114 ; CHECK-NEXT: end_block
115 ; CHECK-NEXT: i64.trunc_f32_u $push[[NUM:[0-9]+]]=, $0{{$}}
116 ; CHECK-NEXT: return $pop[[NUM]]{{$}}
117123 define i64 @i64_trunc_u_f32(float %x) {
118124 %a = fptoui float %x to i64
119125 ret i64 %a
125131 ; CHECK-NEXT: f64.abs $push[[ABS:[0-9]+]]=, $0{{$}}
126132 ; CHECK-NEXT: f64.const $push[[LIMIT:[0-9]+]]=, 0x1p63{{$}}
127133 ; CHECK-NEXT: f64.lt $push[[LT:[0-9]+]]=, $pop[[ABS]], $pop[[LIMIT]]{{$}}
128 ; CHECK-NEXT: br_if 0, $pop[[LT]]{{$}}
134 ; CHECK-NEXT: i32.eqz $push[[EQZ:[0-9]+]]=, $pop[[LT]]
135 ; CHECK-NEXT: br_if 0, $pop[[EQZ]]{{$}}
136 ; CHECK-NEXT: i64.trunc_f64_s $push[[NUM:[0-9]+]]=, $0{{$}}
137 ; CHECK-NEXT: return $pop[[NUM]]{{$}}
138 ; CHECK-NEXT: BB
139 ; CHECK-NEXT: end_block
129140 ; CHECK-NEXT: i64.const $push[[ALT:[0-9]+]]=, -9223372036854775808{{$}}
130141 ; CHECK-NEXT: return $pop[[ALT]]{{$}}
131 ; CHECK-NEXT: BB
132 ; CHECK-NEXT: end_block
133 ; CHECK-NEXT: i64.trunc_f64_s $push[[NUM:[0-9]+]]=, $0{{$}}
134 ; CHECK-NEXT: return $pop[[NUM]]{{$}}
135142 define i64 @i64_trunc_s_f64(double %x) {
136143 %a = fptosi double %x to i64
137144 ret i64 %a
145152 ; CHECK-NEXT: f64.const $push[[ZERO:[0-9]+]]=, 0x0p0{{$}}
146153 ; CHECK-NEXT: f64.ge $push[[GE:[0-9]+]]=, $0, $pop[[ZERO]]{{$}}
147154 ; CHECK-NEXT: i32.and $push[[AND:[0-9]+]]=, $pop[[LT]], $pop[[GE]]{{$}}
148 ; CHECK-NEXT: br_if 0, $pop[[AND]]{{$}}
155 ; CHECK-NEXT: i32.eqz $push[[EQZ:[0-9]+]]=, $pop[[AND]]
156 ; CHECK-NEXT: br_if 0, $pop[[EQZ]]{{$}}
157 ; CHECK-NEXT: i64.trunc_f64_u $push[[NUM:[0-9]+]]=, $0{{$}}
158 ; CHECK-NEXT: return $pop[[NUM]]{{$}}
159 ; CHECK-NEXT: BB
160 ; CHECK-NEXT: end_block
149161 ; CHECK-NEXT: i64.const $push[[ALT:[0-9]+]]=, 0{{$}}
150162 ; CHECK-NEXT: return $pop[[ALT]]{{$}}
151 ; CHECK-NEXT: BB
152 ; CHECK-NEXT: end_block
153 ; CHECK-NEXT: i64.trunc_f64_u $push[[NUM:[0-9]+]]=, $0{{$}}
154 ; CHECK-NEXT: return $pop[[NUM]]{{$}}
155163 define i64 @i64_trunc_u_f64(double %x) {
156164 %a = fptoui double %x to i64
157165 ret i64 %a
66 ; CONST_XXX instructions to provide an explicit push.
77
88 ; CHECK-LABEL: implicit_def_i32:
9 ; CHECK: .LBB{{[0-9]+}}_4:{{$}}
10 ; CHECK-NEXT: end_block{{$}}
11 ; CHECK-NEXT: i32.const $push[[R:[0-9]+]]=, 0{{$}}
9 ; CHECK: i32.const $push{{[0-9]+}}=, 0{{$}}
10 ; CHECK: i32.const $push{{[0-9]+}}=, 0{{$}}
11 ; CHECK: i32.const $push[[R:[0-9]+]]=, 0{{$}}
1212 ; CHECK-NEXT: return $pop[[R]]{{$}}
13 ; CHECK-NEXT: end_function{{$}}
1413 define i32 @implicit_def_i32() {
1514 br i1 undef, label %A, label %X
1615
3130 }
3231
3332 ; CHECK-LABEL: implicit_def_i64:
34 ; CHECK: .LBB{{[0-9]+}}_4:{{$}}
35 ; CHECK-NEXT: end_block{{$}}
36 ; CHECK-NEXT: i64.const $push[[R:[0-9]+]]=, 0{{$}}
33 ; CHECK: i64.const $push[[R:[0-9]+]]=, 0{{$}}
3734 ; CHECK-NEXT: return $pop[[R]]{{$}}
38 ; CHECK-NEXT: end_function{{$}}
3935 define i64 @implicit_def_i64() {
4036 br i1 undef, label %A, label %X
4137
5652 }
5753
5854 ; CHECK-LABEL: implicit_def_f32:
59 ; CHECK: .LBB{{[0-9]+}}_4:{{$}}
60 ; CHECK-NEXT: end_block{{$}}
61 ; CHECK-NEXT: f32.const $push[[R:[0-9]+]]=, 0x0p0{{$}}
55 ; CHECK: f32.const $push[[R:[0-9]+]]=, 0x0p0{{$}}
6256 ; CHECK-NEXT: return $pop[[R]]{{$}}
63 ; CHECK-NEXT: end_function{{$}}
6457 define float @implicit_def_f32() {
6558 br i1 undef, label %A, label %X
6659
8174 }
8275
8376 ; CHECK-LABEL: implicit_def_f64:
84 ; CHECK: .LBB{{[0-9]+}}_4:{{$}}
85 ; CHECK-NEXT: end_block{{$}}
86 ; CHECK-NEXT: f64.const $push[[R:[0-9]+]]=, 0x0p0{{$}}
77 ; CHECK: f64.const $push[[R:[0-9]+]]=, 0x0p0{{$}}
8778 ; CHECK-NEXT: return $pop[[R]]{{$}}
88 ; CHECK-NEXT: end_function{{$}}
8979 define double @implicit_def_f64() {
9080 br i1 undef, label %A, label %X
9181
10696 }
10797
10898 ; CHECK-LABEL: implicit_def_v4i32:
109 ; CHECK: .LBB{{[0-9]+}}_4:{{$}}
110 ; CHECK-NEXT: end_block{{$}}
111 ; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, 0{{$}}
99 ; CHECK: i32.const $push{{[0-9]+}}=, 0{{$}}
100 ; CHECK: i32.const $push{{[0-9]+}}=, 0{{$}}
101 ; CHECK: i32.const $push[[L0:[0-9]+]]=, 0{{$}}
112102 ; CHECK-NEXT: i32x4.splat $push[[R:[0-9]+]]=, $pop[[L0]]
113103 ; CHECK-NEXT: return $pop[[R]]{{$}}
114 ; CHECK-NEXT: end_function{{$}}
115104 define <4 x i32> @implicit_def_v4i32() {
116105 br i1 undef, label %A, label %X
117106
4848 ; CHECK-NEXT: i32.const $push1=, 0
4949 ; CHECK-NEXT: i32.const $push0=, __dso_handle
5050 ; CHECK-NEXT: i32.call $push3=, __cxa_atexit, $pop2, $pop1, $pop0{{$}}
51 ; CHECK-NEXT: br_if 0, $pop3
52 ; CHECK-NEXT: return
51 ; CHECK-NEXT: i32.eqz $push4=, $pop3
52 ; CHECK-NEXT: br_if 0, $pop4
53 ; CHECK-NEXT: unreachable
5354 ; CHECK: end_block
54 ; CHECK-NEXT: unreachable
5555
5656 ; CHECK-LABEL: .Lcall_dtors.1:
5757 ; CHECK-NEXT: .functype .Lcall_dtors.1 (i32) -> (){{$}}
6464 ; CHECK-NEXT: i32.const $push1=, 0
6565 ; CHECK-NEXT: i32.const $push0=, __dso_handle
6666 ; CHECK-NEXT: i32.call $push3=, __cxa_atexit, $pop2, $pop1, $pop0{{$}}
67 ; CHECK-NEXT: br_if 0, $pop3
68 ; CHECK-NEXT: return
67 ; CHECK-NEXT: i32.eqz $push4=, $pop3
68 ; CHECK-NEXT: br_if 0, $pop4
69 ; CHECK-NEXT: unreachable
6970 ; CHECK: end_block
70 ; CHECK-NEXT: unreachable
7171
7272 ; CHECK-LABEL: .Lcall_dtors.1.associated1c0:
7373 ; CHECK-NEXT: .functype .Lcall_dtors.1.associated1c0 (i32) -> (){{$}}
7979 ; CHECK-NEXT: i32.const $push1=, 0
8080 ; CHECK-NEXT: i32.const $push0=, __dso_handle
8181 ; CHECK-NEXT: i32.call $push3=, __cxa_atexit, $pop2, $pop1, $pop0{{$}}
82 ; CHECK-NEXT: br_if 0, $pop3
83 ; CHECK-NEXT: return
84 ; CHECK: end_block
82 ; CHECK-NEXT: i32.eqz $push4=, $pop3
83 ; CHECK-NEXT: br_if 0, $pop4
8584 ; CHECK-NEXT: unreachable
8685
8786 ; CHECK-LABEL: .Lcall_dtors.1.associated1c1:
9594 ; CHECK-NEXT: i32.const $push1=, 0
9695 ; CHECK-NEXT: i32.const $push0=, __dso_handle
9796 ; CHECK-NEXT: i32.call $push3=, __cxa_atexit, $pop2, $pop1, $pop0{{$}}
98 ; CHECK-NEXT: br_if 0, $pop3
99 ; CHECK-NEXT: return
100 ; CHECK: end_block
97 ; CHECK-NEXT: i32.eqz $push4=, $pop3
98 ; CHECK-NEXT: br_if 0, $pop4
10199 ; CHECK-NEXT: unreachable
102100
103101 ; CHECK-LABEL: .Lcall_dtors:
110108 ; CHECK-NEXT: i32.const $push1=, 0
111109 ; CHECK-NEXT: i32.const $push0=, __dso_handle
112110 ; CHECK-NEXT: i32.call $push3=, __cxa_atexit, $pop2, $pop1, $pop0{{$}}
113 ; CHECK-NEXT: br_if 0, $pop3
114 ; CHECK-NEXT: return
115 ; CHECK: end_block
111 ; CHECK-NEXT: i32.eqz $push4=, $pop3
112 ; CHECK-NEXT: br_if 0, $pop4
116113 ; CHECK-NEXT: unreachable
117114
118115 ; CHECK-LABEL: .section .init_array.0,"",@
77 ; Basic phi triangle.
88
99 ; CHECK-LABEL: test0:
10 ; CHECK: return $0
11 ; CHECK: div_s $push[[NUM0:[0-9]+]]=, $0, $pop[[NUM1:[0-9]+]]{{$}}
12 ; CHECK: return $pop[[NUM0]]{{$}}
10 ; CHECK: div_s $[[NUM0:[0-9]+]]=, $0, $pop[[NUM1:[0-9]+]]{{$}}
11 ; CHECK: return $[[NUM0]]{{$}}
1312 define i32 @test0(i32 %p) {
1413 entry:
1514 %t = icmp slt i32 %p, 0
9292 ; CHECK-NEXT: Body: 1080808080000B
9393 ; CHECK-NEXT: - Index: 6
9494 ; CHECK-NEXT: Locals:
95 ; CHECK-NEXT: Body: 024041818080800041004180808080001081808080000D000F0B00000B
95 ; CHECK-NEXT: Body: 02404181808080004100418080808000108180808000450D0000000B0B
9696 ; CHECK-NEXT: - Index: 7
9797 ; CHECK-NEXT: Locals:
9898 ; CHECK-NEXT: Body: 1082808080000B
9999 ; CHECK-NEXT: - Index: 8
100100 ; CHECK-NEXT: Locals:
101 ; CHECK-NEXT: Body: 024041828080800041004180808080001081808080000D000F0B00000B
101 ; CHECK-NEXT: Body: 02404182808080004100418080808000108180808000450D0000000B0B
102102 ; CHECK-NEXT: - Type: DATA
103103 ; CHECK-NEXT: Segments:
104104 ; CHECK-NEXT: - SectionOffset: 6