blob: 9bf5a812904592e520e5009f5d63b8bc0fb9056c [file] [log] [blame]
Wouter van Oortmerssen8a9cb242018-08-27 15:45:51 +00001; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -disable-block-placement -verify-machineinstrs | FileCheck %s
Dan Gohman950a13c2015-09-16 16:51:30 +00002
Dan Gohmanf0b165a2015-12-05 03:03:35 +00003; Test switch instructions. Block placement is disabled because it reorders
4; the blocks in a way that isn't interesting here.
Dan Gohman950a13c2015-09-16 16:51:30 +00005
Dan Gohman0c6f5ac2016-01-07 03:19:23 +00006target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
Sam Clegga5908002018-05-10 17:49:11 +00007target triple = "wasm32-unknown-unknown"
Dan Gohman950a13c2015-09-16 16:51:30 +00008
9declare void @foo0()
10declare void @foo1()
11declare void @foo2()
12declare void @foo3()
13declare void @foo4()
14declare void @foo5()
15
Dan Gohmane51c0582015-10-06 00:27:55 +000016; CHECK-LABEL: bar32:
Dan Gohman2726b882016-10-06 22:29:32 +000017; CHECK: block {{$}}
18; CHECK: block {{$}}
19; CHECK: block {{$}}
20; CHECK: block {{$}}
21; CHECK: block {{$}}
22; CHECK: block {{$}}
23; CHECK: block {{$}}
Dan Gohman14026062016-03-08 03:18:12 +000024; CHECK: br_table {{[^,]+}}, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 4, 5, 0{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +000025; CHECK: .LBB0_2:
Dan Gohman26c67652016-01-11 23:38:05 +000026; CHECK: call foo0@FUNCTION{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +000027; CHECK: .LBB0_3:
Dan Gohman26c67652016-01-11 23:38:05 +000028; CHECK: call foo1@FUNCTION{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +000029; CHECK: .LBB0_4:
Dan Gohman26c67652016-01-11 23:38:05 +000030; CHECK: call foo2@FUNCTION{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +000031; CHECK: .LBB0_5:
Dan Gohman26c67652016-01-11 23:38:05 +000032; CHECK: call foo3@FUNCTION{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +000033; CHECK: .LBB0_6:
Dan Gohman26c67652016-01-11 23:38:05 +000034; CHECK: call foo4@FUNCTION{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +000035; CHECK: .LBB0_7:
Dan Gohman26c67652016-01-11 23:38:05 +000036; CHECK: call foo5@FUNCTION{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +000037; CHECK: .LBB0_8:
Dan Gohmane51c0582015-10-06 00:27:55 +000038; CHECK: return{{$}}
Dan Gohman950a13c2015-09-16 16:51:30 +000039define void @bar32(i32 %n) {
40entry:
41 switch i32 %n, label %sw.epilog [
42 i32 0, label %sw.bb
43 i32 1, label %sw.bb
44 i32 2, label %sw.bb
45 i32 3, label %sw.bb
46 i32 4, label %sw.bb
47 i32 5, label %sw.bb
48 i32 6, label %sw.bb
49 i32 7, label %sw.bb.1
50 i32 8, label %sw.bb.1
51 i32 9, label %sw.bb.1
52 i32 10, label %sw.bb.1
53 i32 11, label %sw.bb.1
54 i32 12, label %sw.bb.1
55 i32 13, label %sw.bb.1
56 i32 14, label %sw.bb.1
57 i32 15, label %sw.bb.2
58 i32 16, label %sw.bb.2
59 i32 17, label %sw.bb.2
60 i32 18, label %sw.bb.2
61 i32 19, label %sw.bb.2
62 i32 20, label %sw.bb.2
63 i32 21, label %sw.bb.3
64 i32 22, label %sw.bb.4
65 i32 23, label %sw.bb.5
66 ]
67
68sw.bb: ; preds = %entry, %entry, %entry, %entry, %entry, %entry, %entry
69 tail call void @foo0()
70 br label %sw.epilog
71
72sw.bb.1: ; preds = %entry, %entry, %entry, %entry, %entry, %entry, %entry, %entry
73 tail call void @foo1()
74 br label %sw.epilog
75
76sw.bb.2: ; preds = %entry, %entry, %entry, %entry, %entry, %entry
77 tail call void @foo2()
78 br label %sw.epilog
79
80sw.bb.3: ; preds = %entry
81 tail call void @foo3()
82 br label %sw.epilog
83
84sw.bb.4: ; preds = %entry
85 tail call void @foo4()
86 br label %sw.epilog
87
88sw.bb.5: ; preds = %entry
89 tail call void @foo5()
90 br label %sw.epilog
91
92sw.epilog: ; preds = %entry, %sw.bb.5, %sw.bb.4, %sw.bb.3, %sw.bb.2, %sw.bb.1, %sw.bb
93 ret void
94}
95
Dan Gohmane51c0582015-10-06 00:27:55 +000096; CHECK-LABEL: bar64:
Dan Gohman2726b882016-10-06 22:29:32 +000097; CHECK: block {{$}}
98; CHECK: block {{$}}
99; CHECK: block {{$}}
100; CHECK: block {{$}}
101; CHECK: block {{$}}
102; CHECK: block {{$}}
103; CHECK: block {{$}}
Dan Gohman14026062016-03-08 03:18:12 +0000104; CHECK: br_table {{[^,]+}}, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 4, 5, 0{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000105; CHECK: .LBB1_2:
Dan Gohman26c67652016-01-11 23:38:05 +0000106; CHECK: call foo0@FUNCTION{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000107; CHECK: .LBB1_3:
Dan Gohman26c67652016-01-11 23:38:05 +0000108; CHECK: call foo1@FUNCTION{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000109; CHECK: .LBB1_4:
Dan Gohman26c67652016-01-11 23:38:05 +0000110; CHECK: call foo2@FUNCTION{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000111; CHECK: .LBB1_5:
Dan Gohman26c67652016-01-11 23:38:05 +0000112; CHECK: call foo3@FUNCTION{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000113; CHECK: .LBB1_6:
Dan Gohman26c67652016-01-11 23:38:05 +0000114; CHECK: call foo4@FUNCTION{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000115; CHECK: .LBB1_7:
Dan Gohman26c67652016-01-11 23:38:05 +0000116; CHECK: call foo5@FUNCTION{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000117; CHECK: .LBB1_8:
Dan Gohmane51c0582015-10-06 00:27:55 +0000118; CHECK: return{{$}}
Dan Gohman950a13c2015-09-16 16:51:30 +0000119define void @bar64(i64 %n) {
120entry:
121 switch i64 %n, label %sw.epilog [
122 i64 0, label %sw.bb
123 i64 1, label %sw.bb
124 i64 2, label %sw.bb
125 i64 3, label %sw.bb
126 i64 4, label %sw.bb
127 i64 5, label %sw.bb
128 i64 6, label %sw.bb
129 i64 7, label %sw.bb.1
130 i64 8, label %sw.bb.1
131 i64 9, label %sw.bb.1
132 i64 10, label %sw.bb.1
133 i64 11, label %sw.bb.1
134 i64 12, label %sw.bb.1
135 i64 13, label %sw.bb.1
136 i64 14, label %sw.bb.1
137 i64 15, label %sw.bb.2
138 i64 16, label %sw.bb.2
139 i64 17, label %sw.bb.2
140 i64 18, label %sw.bb.2
141 i64 19, label %sw.bb.2
142 i64 20, label %sw.bb.2
143 i64 21, label %sw.bb.3
144 i64 22, label %sw.bb.4
145 i64 23, label %sw.bb.5
146 ]
147
148sw.bb: ; preds = %entry, %entry, %entry, %entry, %entry, %entry, %entry
149 tail call void @foo0()
150 br label %sw.epilog
151
152sw.bb.1: ; preds = %entry, %entry, %entry, %entry, %entry, %entry, %entry, %entry
153 tail call void @foo1()
154 br label %sw.epilog
155
156sw.bb.2: ; preds = %entry, %entry, %entry, %entry, %entry, %entry
157 tail call void @foo2()
158 br label %sw.epilog
159
160sw.bb.3: ; preds = %entry
161 tail call void @foo3()
162 br label %sw.epilog
163
164sw.bb.4: ; preds = %entry
165 tail call void @foo4()
166 br label %sw.epilog
167
168sw.bb.5: ; preds = %entry
169 tail call void @foo5()
170 br label %sw.epilog
171
172sw.epilog: ; preds = %entry, %sw.bb.5, %sw.bb.4, %sw.bb.3, %sw.bb.2, %sw.bb.1, %sw.bb
173 ret void
174}